Dummyclass for Gameobjects

This commit is contained in:
2024-01-16 21:26:36 +01:00
parent e01d187ea5
commit 410ce9f72b
2 changed files with 25 additions and 2 deletions

View File

@@ -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
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

View File

@@ -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)