Example #1
0
def screen(img):
	surface.fill((0, 0, 64))
	surface.blit(img, (0, 0, xres, yres))
	pygame.display.flip()
	while True:
		events = pygame.event.get()
		for e in events:
			if e.type == QUIT:
				quit()
			if e.type == KEYDOWN:
				return
Example #2
0
	def drawLayout(self, arg):
		surface.fill((0, 0, 0))

		for vp in self.vps:
			vpa, vpb = vp
			vpa.paint(arg)
			surface.blit(vpa.surface, vpb, None, BLEND_ADD)

		# viewport borders
		if len(self.players) == 2:
			pygame.draw.line(surface, (192, 192, 192), (xres / 2 - 1, 0), (xres / 2 - 1, yres))
		elif len(self.players) == 3:
			pygame.draw.line(surface, (192, 192, 192), (xres / 3 - 1, 0), (xres / 3 - 1, yres))
			pygame.draw.line(surface, (192, 192, 192), (2 * xres / 3 - 1, 0), (2 * xres / 3 - 1, yres))
		elif len(self.players) == 4:
			pygame.draw.line(surface, (192, 192, 192), (xres / 2 - 1, 0), (xres / 2 - 1, yres))
			pygame.draw.line(surface, (192, 192, 192), (0, yres / 2 - 1), ( xres, yres / 2 - 1))

		pygame.display.flip()
Example #3
0
def menu():
	fnt = pygame.font.SysFont(pygame.font.get_default_font(), 32)

	item = 0
	items = [
		("Single player", lambda: play(1)),
		("Two players", lambda: play(2)),
		("Three players", lambda: play(3)),
		("Four players", lambda: play(4)),
		("About", lambda: screen(pabout)),
		("Quit", quit),
	]
	while True:
		surface.fill((0, 0, 64))
		surface.blit(menubg, (0, 0, xres, yres))

		ii = 0
		for i in items:
			if ii == item:
				c = menu_active_item
			else:
				c = menu_item
			surface.blit(fnt.render(i[0], False, c), (256, 200 + 64 * ii, 800, 600))
			ii += 1

		events = pygame.event.get()
		for e in events:
			if e.type == QUIT:
				quit()
			if e.type == KEYDOWN:
				if e.key == K_ESCAPE:
					quit()
				if e.key == K_DOWN:
					item += 1
					item %= len(items)
				if e.key == K_UP:
					item -= 1
					item %= len(items)
				if e.key == K_RETURN:
					items[item][1]()

		pygame.display.flip()
		wait()