Ejemplo n.º 1
0
	def __init__(self, game, screen):
		ui.UI.__init__(self, screen)
		self.game = game
		self.playersWidgets = {}

		''' LEFT BAR '''
		# TODO: Seleção de munição
		panel = pygame.transform.scale(ui.IMAGES['metal_panel'], (250, 150))
		self.addWidget(label.Image([10, 10], panel, centralization=ui.RIGHT | ui.BOTTOM))

		self.timer = label.Text([60, 25], 'Próximo turno: 00', fontsize=15, centralization=ui.RIGHT | ui.BOTTOM)
		self.addWidget(self.timer)

		self.fuel = bar.Bar([panel.get_size()[0] / 2 + 10, 60],
						size=[panel.get_size()[0] - 60, 15],
						min=0, max=100, initial=100,
						image_bar_left=ui.IMAGES['bar_yellow_left'],
						image_bar_mid=ui.IMAGES['bar_yellow_mid'],
						image_bar_right=ui.IMAGES['bar_yellow_right'])
		self.addWidget(self.fuel)
		self.addWidget(label.Text([panel.get_size()[0] // 5, 54], 'Combustível', centralization=ui.RIGHT | ui.BOTTOM))

		''' RIGHT BAR '''
		panelLife = pygame.transform.scale(ui.IMAGES['metal_panel'], (250, len(self.game.getLiveEntities()) * 20 + 60))
		self.addWidget(label.Image([my.SCREEN_WIDTH - 10, 10], panelLife, centralization=ui.LEFT | ui.BOTTOM))
		self.addWidget(label.Text([my.SCREEN_WIDTH - 65, 25], 'Vida dos jogadores', centralization=ui.LEFT | ui.BOTTOM))

		y = 40
		for entity in self.game.getLiveEntities():
			y += 20
			self.playersWidgets[entity.id] = [
				label.Text([entity.pos[0], entity.pos[1] - 50], entity.nickname, high=True),

				bar.Bar([entity.pos[0], entity.pos[1] - 40],
						size=[entity.image.get_width(), 20],
						min=0, max=entity.health, initial=entity.health,
						image_bar_left=ui.IMAGES['bar_red_left'],
						image_bar_mid=ui.IMAGES['bar_red_mid'],
						image_bar_right=ui.IMAGES['bar_red_right']),

				bar.Bar([my.SCREEN_WIDTH - panelLife.get_size()[0] / 2 - 10, y],
						size=[panelLife.get_size()[0] - 60, 15],
						min=0, max=entity.health, initial=entity.health,
						image_bar_left=ui.IMAGES['bar_red_left'],
						image_bar_mid=ui.IMAGES['bar_red_mid'],
						image_bar_right=ui.IMAGES['bar_red_right'])]

			#self.addWidget(self.playersWidgets[entity.id][0])
			#self.addWidget(self.playersWidgets[entity.id][1])
			self.addWidget(self.playersWidgets[entity.id][2])

			self.addWidget(label.Text([my.SCREEN_WIDTH - panelLife.get_size()[0] + 25, y - 7], entity.nickname,
									  centralization=ui.RIGHT | ui.BOTTOM))

		self.next = self
Ejemplo n.º 2
0
	def __init__(self, screen):
		ui.UI.__init__(self, screen)

		self.fpsValue = label.Text([my.SCREEN_HALF_WIDTH + 25, my.SCREEN_HEIGHT // 6], str(my.FPS), fontsize=20)
		self.addWidget(self.fpsValue)
		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH - 25, my.SCREEN_HEIGHT // 6], "FPS", fontsize=20))
		self.addWidget(slider.SliderBar(partial(self.sliderFps), [my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT // 4], (300, 5), min=20,
							 max=200, step=1,
							 initial=my.FPS,
							 image_slider=ui.IMAGES['slider'],
							 image_pointer=ui.IMAGES['slider_pointer']))

		contents = []
		modes = pygame.display.list_modes()
		for mode in range(0, len(modes) - 5):  # -5 = Tirando os 5 menores valores pois é pequeno até demais pro jogo
			contents.append(str(modes[mode][0]) + ' x ' + str(modes[mode][1]) + (' (FULL)' if mode == 0 else ''))
		self.addWidget(button.Drop(self, contents,
								   partial(self.selectResolution),
								   [my.SCREEN_HALF_WIDTH, my.SCREEN_HALF_HEIGHT - 50],
								   text="Resolução",
								   image_surface=ui.IMAGES['button'],
								   image_pressed=ui.IMAGES['button_pressed'],
								   down=True))

		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH + 30, my.SCREEN_HALF_HEIGHT], "Acelerar CPU (tela cheia)", fontsize=20))
		self.addWidget(checker.Checker(partial(self.checkedHardware),
									   [my.SCREEN_HALF_WIDTH - 150, my.SCREEN_HALF_HEIGHT],
									   checked=my.HARDWARE_ACCELERATED,
									   image=ui.IMAGES['box'],
									   image_checked=ui.IMAGES['box_checked']))

		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH + 20, my.SCREEN_HALF_HEIGHT + 40], "Áudio, sons e vozes", fontsize=20))
		self.addWidget(checker.Checker(partial(self.checkedAudio),
									   [my.SCREEN_HALF_WIDTH - 150, my.SCREEN_HALF_HEIGHT + 40],
									   checked=not my.MUTED,
									   image=ui.IMAGES['box'],
									   image_checked=ui.IMAGES['box_checked']))

		self.addWidget(button.ImageButton(lambda: self.back(),
										  [my.SCREEN_HALF_WIDTH - 20, my.SCREEN_HEIGHT - (my.SCREEN_HEIGHT // 6)],
										  text="Voltar",
										  image_surface=ui.IMAGES['button'],
										  image_pressed=ui.IMAGES['button_pressed'],
										  centralization=ui.LEFT))
		self.addWidget(button.ImageButton(lambda: self.save(),
										  [my.SCREEN_HALF_WIDTH + 20, my.SCREEN_HEIGHT - (my.SCREEN_HEIGHT // 6)],
										  text="Salvar",
										  image_surface=ui.IMAGES['button_green'],
										  image_pressed=ui.IMAGES['button_green_pressed'],
										  centralization=ui.RIGHT))
		self.next = self
Ejemplo n.º 3
0
    def __init__(self, screen):
        ui.UI.__init__(self, screen)

        self.text = label.Text(my.SCREEN_HALF_SIZE, 'Vencedor!', fontsize=20)
        self.addWidget(self.bar)

        self.next = self
Ejemplo n.º 4
0
	def __init__(self, screen):
		ui.UI.__init__(self, screen)

		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH, 100], "Desenvolvido por:", fontsize=24))
		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH, 140], "Willian Gois ~the coder guy", fontsize=20))
		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH, 160], "Lucas Verona ~the h4ck3r m4n", fontsize=20))

		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH, 220], "Texturas por:", fontsize=24))
		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH, 260], "(UI): Kenney Vleugels (www.kenney.nl)", fontsize=20))

		self.addWidget(button.ImageButton(lambda: self.back(),
										  [my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT - (my.SCREEN_HEIGHT // 6)],
										  text="Voltar",
										  image_surface=ui.IMAGES['button'],
										  image_pressed=ui.IMAGES['button_pressed']))

		self.next = self
Ejemplo n.º 5
0
	def __init__(self, screen):
		ui.UI.__init__(self, screen)

		self.addWidget(label.Text([50, 50], "Configure o jogo:", fontsize=18, centralization=ui.RIGHT))

		self.addWidget(input.TextBox(partial(self.inputName), [my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT // 6], [300, 40],
									 'Digite seu nicknme',
									 box_image=ui.IMAGES['button']))
		self.nickname = 'Jogador'

		self.enemiesValue = label.Text([my.SCREEN_HALF_WIDTH + 50, my.SCREEN_HALF_HEIGHT // 2 + 40], "5", fontsize=18)
		self.addWidget(self.enemiesValue)
		self.addWidget(label.Text([my.SCREEN_HALF_WIDTH - 10, my.SCREEN_HALF_HEIGHT // 2 + 40], "Inimigos", fontsize=18))
		self.addWidget(slider.SliderBar(partial(self.sliderEnemies), [my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT // 3 + 32], (200, 5),
							 min=1, max=10, step=1,
							 initial=5,
							 image_slider=ui.IMAGES['slider'],
							 image_pointer=ui.IMAGES['slider_pointer']))

		self.mapSize = [my.SCREEN_WIDTH, my.SCREEN_HEIGHT + 200]
		contents = []
		for i in range(0, 500, 100):
			contents.append(str(my.SCREEN_WIDTH + i) + ' x ' + str(my.SCREEN_HEIGHT + 200))
		self.addWidget(button.Drop(self, contents,
								   partial(self.selectMapSize),
								   [my.SCREEN_HALF_WIDTH, my.SCREEN_HALF_HEIGHT],
								   text="Tamanho do Mapa",
								   image_surface=pygame.transform.scale(ui.IMAGES['button'], (270, 50)),
								   image_pressed=pygame.transform.scale(ui.IMAGES['button_pressed'], (270, 50)),
								   down=True))

		self.addWidget(button.ImageButton(lambda: self.back(),
										  [my.SCREEN_HALF_WIDTH - 20, my.SCREEN_HEIGHT - (my.SCREEN_HEIGHT // 6)],
										  text="Voltar",
										  image_surface=ui.IMAGES['button'],
										  image_pressed=ui.IMAGES['button_pressed'],
										  centralization=ui.LEFT))
		self.addWidget(button.ImageButton(lambda: self.startGame(),
										  [my.SCREEN_HALF_WIDTH + 20, my.SCREEN_HEIGHT - (my.SCREEN_HEIGHT // 6)],
										  text="Iniciar Jogo",
										  image_surface=ui.IMAGES['button_green'],
										  image_pressed=ui.IMAGES['button_green_pressed'],
										  centralization=ui.RIGHT))

		self.next = self
Ejemplo n.º 6
0
    def doTurnAnimation(self):
        text = label.Text(my.SCREEN_HALF_SIZE,
                          'Seu turno é agora!' if self.currentEntity
                          == self.game.player else 'Turno de: ' +
                          self.currentEntity.nickname,
                          fontsize=30)
        self.game.hud.addWidget(text)

        lib.delayedfunc.DelayedFunc(partial(self.game.hud.removeWidget, text),
                                    2)
Ejemplo n.º 7
0
	def onDeath(self):
		sound.play('game_over')
		text = label.Text((my.SCREEN_HALF_WIDTH, my.SCREEN_HALF_HEIGHT - 50), "Você perdeu!", fontsize=30)
		self.game.hud.addWidget(text)

		def remove():
			self.game.hud.removeWidget(text)
			self.game.end()

		lib.delayedfunc.DelayedFunc(lambda: remove(), 5)
Ejemplo n.º 8
0
	def __init__(self, screen):
		ui.UI.__init__(self, screen)

		self.addWidget(label.Text(my.SCREEN_HALF_SIZE, "Em desenvolvimento...", fontsize=24))
		self.addWidget(button.ImageButton(lambda: self.back(),
										  [my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT - (my.SCREEN_HEIGHT // 6)],
										  text="Voltar",
										  image_surface=ui.IMAGES['button'],
										  image_pressed=ui.IMAGES['button_pressed']))

		self.next = self
Ejemplo n.º 9
0
	def __init__(self, screen):
		ui.UI.__init__(self, screen)

		self.text = label.Text(my.SCREEN_HALF_SIZE, 'Gerando mapa...', fontsize=20)
		self.bar = bar.Bar([my.SCREEN_HALF_HEIGHT+100, my.SCREEN_HALF_HEIGHT+30], size=[400, 20],
							min=0, max=100, initial=1,
							image_bar_left=ui.IMAGES['bar_red_left'],
							image_bar_mid=ui.IMAGES['bar_red_mid'],
							image_bar_right=ui.IMAGES['bar_red_right'])

		self.addWidget(self.text)
		self.addWidget(self.bar)

		self.next = self
Ejemplo n.º 10
0
	def __init__(self, screen):
		ui.UI.__init__(self, screen)
		global BACKGROUND
		BACKGROUND = pygame.transform.scale(ui.IMAGES['background'], my.SCREEN_SIZE)

		self.logo = label.Image([my.SCREEN_HALF_WIDTH, -my.SCREEN_HEIGHT], pygame.image.load("assets/logo.png"),
								centralization=ui.BOTTOM)
		self.addWidget(self.logo)

		self.playOfflineButton = button.ImageButton(lambda: self.playOffline(),
													[my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT],
													text="Jogar Offline",
													image_surface=ui.IMAGES['button'],
													image_pressed=ui.IMAGES['button_pressed'])
		self.playOnlineButton = button.ImageButton(lambda: self.playOnline(),
												   [my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT],
												   text="Jogar Online",
												   image_surface=ui.IMAGES['button'],
												   image_pressed=ui.IMAGES['button_pressed'])
		self.optionsButton = button.ImageButton(lambda: self.options(),
												[my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT],
												text="Opções",
												image_surface=ui.IMAGES['button'],
												image_pressed=ui.IMAGES['button_pressed'])
		self.creditsButton = button.ImageButton(lambda: self.credits(),
												[my.SCREEN_HALF_WIDTH, my.SCREEN_HEIGHT],
												text="Créditos",
												image_surface=ui.IMAGES['button'],
												image_pressed=ui.IMAGES['button_pressed'])
		self.addWidget(self.playOfflineButton)
		self.addWidget(self.playOnlineButton)
		self.addWidget(self.optionsButton)
		self.addWidget(self.creditsButton)
		self.addWidget(label.Text([my.SCREEN_WIDTH - 5, my.SCREEN_HEIGHT], "Tanks v" + my.VERSION, 20, centralization=ui.LEFT | ui.UPPER))

		self.animation = True
		self.readyToNext = False
		self.next = self