From 410ce9f72bdceb812af3666be660fb4d3f511c53 Mon Sep 17 00:00:00 2001 From: administrator Date: Tue, 16 Jan 2024 21:26:36 +0100 Subject: [PATCH] Dummyclass for Gameobjects --- modules/GameObject.py | 22 +++++++++++++++++++++- pygame-test.py | 5 ++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/GameObject.py b/modules/GameObject.py index 817cda1..65c9e1a 100644 --- a/modules/GameObject.py +++ b/modules/GameObject.py @@ -147,6 +147,9 @@ class GameObject(): def get_player_score(self) -> int: return self.__score + def get_surface(self) -> pygame.Surface: + return self.__surface + def has_follower(self): return self.__has_follower @@ -225,4 +228,21 @@ class Player(GameObject): super().__init__(name, surface, mainscreensize, posx_init, posy_init, move_speed, is_player, is_rect, rect_size) def user_test_func(self): - pass \ No newline at end of file + pass + +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, rect_size: tuple = (10, 10), image=str()) -> None: + super().__init__(name, surface, mainscreensize, posx_init, posy_init, move_speed, is_player, is_rect, rect_size, image) + + self.__image = pygame.image.load(image).convert() + + def move(self): + pass + + def draw(self): + print(self.get_surface()) + surface = self.get_surface() + surface.blit(self.__image, self.get_position()) + pass + + \ No newline at end of file diff --git a/pygame-test.py b/pygame-test.py index 4213e5c..14ac78d 100644 --- a/pygame-test.py +++ b/pygame-test.py @@ -78,6 +78,8 @@ player = Player("Player", MAINSCREEN, MAINSCREEN_SIZE, 10, 10, 10, is_player=Fal testobj = GameObject("TESTOBJEKT", MAINSCREEN, MAINSCREEN_SIZE, 0,0,0,image="data/models/testmodel.bmp") test = pygame.image.load("data/models/testmodel.bmp").convert() +goo = GOIMAGE("TESTOBJEKT", MAINSCREEN, MAINSCREEN_SIZE, 0,0,0,image="data/models/testmodel.bmp") + background = pygame.surface.Surface((640,480)) @@ -93,7 +95,7 @@ print("Es wurden " + str(count_spawend_enities)+ " Objekte gespawnt") testx = 10 testy = 10 -#Fenster-Hauptschleife +#Fenster-Hauptschleife+ while active == True: MAINSCREEN.fill((255,255,255)) for event in pygame.event.get(): @@ -118,6 +120,7 @@ while active == True: testx += 1 if(testx >= MAINSCREEN_SIZE[0]): testx = (0 - test.get_size()[0]) MAINSCREEN.blit(test, (testx,testy)) + goo.draw() player.draw() player.update_pos_lastframe(player.get_position()[0], player.get_position()[1], False)