Update Fruit class
Added multiplie fruitcolors and spawn them random
This commit is contained in:
@@ -263,21 +263,29 @@ class Player(GameObject_new):
|
||||
def get_player_rect(self):
|
||||
return self.__player_rect
|
||||
|
||||
def get_playermovedirection(self):
|
||||
return self.__movedirection
|
||||
|
||||
def inc_score(self, points:int):
|
||||
self._score += points
|
||||
|
||||
|
||||
class Fruit(GameObject_new):
|
||||
def __init__(self, name: str, surface: pygame.Surface, surface_size: tuple, init_pos_x, init_pos_y, visibility: bool = True, rect_size:int = 10, color:tuple = (0,0,0), score_points = 0) -> None:
|
||||
def __init__(self, name: str, surface: pygame.Surface, surface_size: tuple, init_pos_x, init_pos_y, visibility: bool = True, rect_size:int = 10, color:tuple = (0,0,0), score_points = 0, sprite=str()) -> None:
|
||||
super().__init__(name, surface, surface_size, init_pos_x, init_pos_y, visibility)
|
||||
|
||||
self.__score_points = score_points
|
||||
self.__rect:pygame.Rect
|
||||
self.__rect_size = rect_size
|
||||
self.__color = color
|
||||
self.__image = pygame.image.load(sprite)
|
||||
|
||||
def draw(self):
|
||||
self.__rect = pygame.draw.rect(self._surface, self.__color, (self._position[0], self._position[1], self.__rect_size, self.__rect_size))
|
||||
#self.__rect = pygame.draw.rect(self._surface, self.__color, (self._position[0], self._position[1], self.__rect_size, self.__rect_size))
|
||||
self.__rect = self._surface.blit(self.__image, self.get_position())
|
||||
|
||||
|
||||
|
||||
|
||||
def get_rect(self) -> pygame.Rect:
|
||||
return self.__rect
|
||||
|
||||
Reference in New Issue
Block a user