programming-bongocat/bongocat.py
2018-12-10 23:05:51 +02:00

45 lines
1.3 KiB
Python

import pygame
class Bongocat:
bongocat_plain = None
left_paw_lifted = None
left_paw_down = None
right_paw_lifted = None
right_paw_down = None
rect = None
is_left_paw_pressing = False
is_right_paw_pressing = False
def load(self):
self.bongocat_plain = pygame.image.load("img/bongocat_plain.png")
self.left_paw_lifted = pygame.image.load("img/left_paw_lifted.png")
self.left_paw_down = pygame.image.load("img/left_paw_down.png")
self.right_paw_lifted = pygame.image.load("img/right_paw_lifted.png")
self.right_paw_down = pygame.image.load("img/right_paw_down.png")
self.rect = self.bongocat_plain.get_rect()
def draw(self, screen):
screen.blit(self.bongocat_plain, self.rect)
if self.is_left_paw_pressing:
screen.blit(self.left_paw_down, self.rect)
else:
screen.blit(self.left_paw_lifted, self.rect)
if self.is_right_paw_pressing:
screen.blit(self.right_paw_down, self.rect)
else:
screen.blit(self.right_paw_lifted, self.rect)
def left_paw_pressing(self, pressing):
self.is_left_paw_pressing = pressing
def right_paw_pressing(self, pressing):
self.is_right_paw_pressing = pressing