bongocat.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import pygame
  2. class Bongocat:
  3. bongocat_plain = None
  4. left_paw_lifted = None
  5. left_paw_down = None
  6. right_paw_lifted = None
  7. right_paw_down = None
  8. rect = None
  9. is_left_paw_pressing = False
  10. is_right_paw_pressing = False
  11. def load(self):
  12. self.bongocat_plain = pygame.image.load("img/bongocat_plain.png")
  13. self.left_paw_lifted = pygame.image.load("img/left_paw_lifted.png")
  14. self.left_paw_down = pygame.image.load("img/left_paw_down.png")
  15. self.right_paw_lifted = pygame.image.load("img/right_paw_lifted.png")
  16. self.right_paw_down = pygame.image.load("img/right_paw_down.png")
  17. self.rect = self.bongocat_plain.get_rect()
  18. def draw(self, screen):
  19. screen.blit(self.bongocat_plain, self.rect)
  20. if self.is_left_paw_pressing:
  21. screen.blit(self.left_paw_down, self.rect)
  22. else:
  23. screen.blit(self.left_paw_lifted, self.rect)
  24. if self.is_right_paw_pressing:
  25. screen.blit(self.right_paw_down, self.rect)
  26. else:
  27. screen.blit(self.right_paw_lifted, self.rect)
  28. def left_paw_pressing(self, pressing):
  29. self.is_left_paw_pressing = pressing
  30. def right_paw_pressing(self, pressing):
  31. self.is_right_paw_pressing = pressing