Guest User

Untitled

a guest
Apr 12th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. def Battle_Screen(self, player, enemy):
  2. turn = 0
  3. def is_odd(turn):
  4. return turn % 2 == 0
  5.  
  6. player_hp = player.hp
  7. enemy_hp = enemy.hp
  8. attack_button = Button(650, 520, 100, 50, WHITE, BLACK, 'Attack', 32)
  9. self.start_time = pygame.time.get_ticks()
  10. while g.battle == 1:
  11.  
  12. mouse_pos = pygame.mouse.get_pos()
  13. mouse_pressed = pygame.mouse.get_pressed()
  14. hpmeter = self.font.render(str(player_hp), True, BLACK)
  15. hpmeter_rect = hpmeter.get_rect(x = 720, y = 475)
  16. enemyhpmeter = self.font.render(str(enemy_hp), True, BLACK)
  17. enemyhpmeter_rect = hpmeter.get_rect(x = 460, y = 230)
  18. for event in pygame.event.get():
  19. if event.type == pygame.QUIT:
  20. sys.exit()
  21.  
  22. if (is_odd(turn)):
  23. if attack_button.is_pressed(mouse_pos, mouse_pressed):
  24. enemy_hp -= 2
  25. turn += 1
  26. #Идея в том, что нажав на кнопку атаки мы наносим урон и идёт анимация атаки, и только после анимации идёт следующий ход
  27. else:
  28. player_hp -= 4
  29. turn += 1
  30. #То же самое, нас атакуют, идёт анимация и только тогда идёт следующий ход
  31.  
  32. #В нынешней версии, нажав на кнопку атаки, мы просто бесконечно отнимаем ХП врага, нужно создать иллюзия того что есть ходы.
  33.  
  34.  
  35.  
  36.  
  37. self.screen.blit(self.battle_background, (300,200))
  38. self.screen.blit(hpmeter, hpmeter_rect)
  39. self.screen.blit(enemyhpmeter, enemyhpmeter_rect)
  40. self.screen.blit(attack_button.image, attack_button.rect)
  41. pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment