Added some new classes

This commit is contained in:
Christian
2024-08-16 11:40:14 +02:00
parent ae2e28cfca
commit 0bbe702f8a
8 changed files with 80 additions and 31 deletions

View File

@@ -60,7 +60,7 @@ class Player(GameObject):
if(event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE):
#Fiiirrreee in the hole
print("Feuer!")
#print("Feuer!")
self.fire(self.screen)
def move(self, x=0, y=0):
@@ -115,7 +115,7 @@ class Player2(Player):
if(event.type == pygame.KEYDOWN and event.key == pygame.K_t):
#Fiiirrreee in the hole
print("Feuer!")
#print("Feuer!")
self.fire(self.screen)
def firecontrol(self, screen):
@@ -133,10 +133,13 @@ class Enemy(GameObject):
super().__init__(name, pos_x, pos_y, width, height, image)
self.screen = screen
self.movespeed = 10
self.weapon:Weapons = None
def fire(self, screen):
#print("Schieße!!!!")
shot = Projectile("Enemy", self.pos_x+(self.width/2),self.pos_y+self.height,5,10, screen, 2)
#shot = Projectile("Enemy", self.pos_x+(self.width/2),self.pos_y+self.height,5,10, screen, 2)
self.weapon.fire()
def firecontrol(self, screen):
if(len(Projectile.shots) > 0):
@@ -153,6 +156,11 @@ class Enemy(GameObject):
if(y != 0):
self.pos_y += y
def give_weapon(self, weapon):
self.weapon = weapon
def get_weapon(self):
return self.weapon
def movementqueue_run(self):
pass
@@ -181,24 +189,23 @@ class Projectile(GameObject):
if(self.pos_y >= self.screen.get_size()[1]):
pass
class Weapons(object):
def __init__(self) -> None:
self.type = None
self.damage = 0
self.firerate = 0
self.duration = 0
class Weapons(GameObject):
def __init__(self, name, pos_x, pos_y, width, height, damage, firerate, duration, screen, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)
#self.type = type
self.damage = damage
self.firerate = firerate
self.duration = duration
self.sprite = ""
self.mountingpos = list()
pass
def fire(self):
print(F"Feuere: {self.name}")
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)
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)
class Weapons(GameObject):
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)