Files
test/Enemy.py
Christian 12190aa4db Added playermovement
-Need to implement key hold down
2024-08-08 22:43:55 +02:00

39 lines
1.1 KiB
Python

import pygame
import GameObject
import Utils
class Enemy(GameObject.GameObject):
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
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, (0,0,0), (self.pos_x, self.pos_y, self.width, self.height))
self.pos_y += self.speed