Added itemhandler to game module

This commit is contained in:
Christian
2024-08-22 21:44:44 +02:00
parent b6590d33b8
commit 31a695f099
4 changed files with 45 additions and 5 deletions

View File

@@ -27,7 +27,7 @@ class GameObject(object):
if(self.image is not None):
self.rect = screen.blit(self.image, (self.pos_x, self.pos_y))
else:
print("Kein Image hinterlegt!")
self.rect = pygame.draw.rect(screen, (255,0,0), (self.pos_x, self.pos_y, self.width, self.height))
return
def setpos(self, pos_x, pos_y):
@@ -220,7 +220,15 @@ class Weapons(GameObject):
class Item(GameObject):
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)
self.speed = 5
def move(self, x, y):
self.pos_x += x
self.pos_y += y
pass
class item_extra_life(Item):
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)
super().__init__(name, pos_x, pos_y, width, height, image)
self.speed = 10