Changed enemy class

This commit is contained in:
Christian
2024-08-08 21:30:34 +02:00
parent 874252e94e
commit a990714452
2 changed files with 45 additions and 29 deletions

View File

@@ -3,11 +3,37 @@ import GameObject
import Utils
class Enemy(GameObject.GameObject):
def __init__(self, name, pos_x, pos_y, width, height, image=None) -> None:
shots_fired = list()
def __init__(self, name, pos_x, pos_y, width, height, screen, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)
def fire(self, screen):
print("Schieße!!!!")
shot = Projectile(" ", self.pos_x+(self.width/2),self.pos_y+self.height,10,5, screen)
self.shots_fired.append(shot)
def shoot(self):
if(len(self.shots_fired) > 0):
for shots in self.shots_fired:
shots:Projectile
shots.animate()
def move(self, x=0, y=0):
if(x != 0):
self.pos_x += x
if(y != 0):
self.pos_y += y
#def render(self):
# pass
class Projectile(GameObject.GameObject):
def __init__(self, name, pos_x, pos_y, width, height, screen, image=None) -> None:
super().__init__(name, pos_x, pos_y, width, height, image)
self.screen = screen
self.speed = 10
def animate(self):
self.rect = pygame.draw.rect(self.screen, (255,255,0), (self.pos_x, self.pos_y, self.width, self.height))
self.pos_y += self.speed