Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Battle_Screen(self, player, enemy):
- turn = 0
- def is_odd(turn):
- return turn % 2 == 0
- player_hp = player.hp
- enemy_hp = enemy.hp
- attack_button = Button(650, 520, 100, 50, WHITE, BLACK, 'Attack', 32)
- self.start_time = pygame.time.get_ticks()
- while g.battle == 1:
- mouse_pos = pygame.mouse.get_pos()
- mouse_pressed = pygame.mouse.get_pressed()
- hpmeter = self.font.render(str(player_hp), True, BLACK)
- hpmeter_rect = hpmeter.get_rect(x = 720, y = 475)
- enemyhpmeter = self.font.render(str(enemy_hp), True, BLACK)
- enemyhpmeter_rect = hpmeter.get_rect(x = 460, y = 230)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- sys.exit()
- if (is_odd(turn)):
- if attack_button.is_pressed(mouse_pos, mouse_pressed):
- enemy_hp -= 2
- turn += 1
- #Идея в том, что нажав на кнопку атаки мы наносим урон и идёт анимация атаки, и только после анимации идёт следующий ход
- else:
- player_hp -= 4
- turn += 1
- #То же самое, нас атакуют, идёт анимация и только тогда идёт следующий ход
- #В нынешней версии, нажав на кнопку атаки, мы просто бесконечно отнимаем ХП врага, нужно создать иллюзия того что есть ходы.
- self.screen.blit(self.battle_background, (300,200))
- self.screen.blit(hpmeter, hpmeter_rect)
- self.screen.blit(enemyhpmeter, enemyhpmeter_rect)
- self.screen.blit(attack_button.image, attack_button.rect)
- pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment