diff --git a/data/models/fruit1.jpeg b/data/models/fruit1.jpeg new file mode 100644 index 0000000..2a2b398 Binary files /dev/null and b/data/models/fruit1.jpeg differ diff --git a/modules/GameObject.py b/modules/GameObject.py index 92219e9..8a2a1a5 100644 --- a/modules/GameObject.py +++ b/modules/GameObject.py @@ -287,16 +287,17 @@ class Fruit(GameObject_new): -""" + class GOIMAGE(GameObject): def __init__(self, name: str, surface, mainscreensize: tuple, posx_init: int = 0, posy_init: int = 0, move_speed: int = 0, is_player: bool = False, is_rect: bool = True, color: tuple = (0, 0, 0), rect_size: tuple = (10, 10), image=str()) -> None: super().__init__(name, surface, mainscreensize, posx_init, posy_init, move_speed, is_player, is_rect, color, rect_size, image) self.__image = pygame.image.load(image).convert() + self.__image = pygame.transform.scale(self.__image, (20, 20)) def move(self): pass def draw(self): surface = self.get_surface() - surface.blit(self.__image, self.get_position())""" \ No newline at end of file + surface.blit(self.__image, self.get_position()) \ No newline at end of file diff --git a/pygame-test.py b/pygame-test.py index dda3fad..d4e27b5 100644 --- a/pygame-test.py +++ b/pygame-test.py @@ -93,6 +93,8 @@ def spawn_entities(x:int, list_of_objects:list): background = pygame.surface.Surface((640,480)) +imageobj = GOIMAGE("TEST", PLAYGROUND, PLAYGROUND.get_size(), 50, 50, image="data/models/fruit1.jpeg", rect_size=(15,50)) + x = 3600 invert = False @@ -135,6 +137,8 @@ while active == True: MAINSCREEN.blit(text_surface_score, (MAINSCREEN_SIZE[0]/2-text_surface_score.get_size()[0]/2,0)) #Paints the Scoreboard in Top/Center MAINSCREEN.blit(text_surface_player, (10, 0)) + imageobj.draw() + if(spawn_fruit == True): fruit = Fruit("Fruit", PLAYGROUND, PLAYGROUND.get_size(), init_pos_x=rand.randint(0, PLAYGROUND.get_size()[0]-40), init_pos_y=rand.randint(0, PLAYGROUND.get_size()[1]-40), color=ROT, rect_size=40, score_points=10) spawn_fruit = False