Added new classes
Edited player.get_damage() function
This commit is contained in:
@@ -41,7 +41,7 @@ class GameObject(object):
|
||||
class Player(GameObject):
|
||||
def __init__(self, name, screen, pos_x, pos_y, width, height, image=None) -> None:
|
||||
super().__init__(name, pos_x, pos_y, width, height, image)
|
||||
self._speed = 10
|
||||
self._speed = 8
|
||||
self.screen:pygame.Surface = screen
|
||||
self.points = 0
|
||||
self._health = 100
|
||||
@@ -71,7 +71,11 @@ class Player(GameObject):
|
||||
return self._health
|
||||
|
||||
def get_damage(self, damage:int):
|
||||
self._health -= damage
|
||||
|
||||
if((self._health - damage) <= 0):
|
||||
self._health = 0
|
||||
else:
|
||||
self._health -= damage
|
||||
|
||||
def move(self, x=0, y=0):
|
||||
if x != 0:
|
||||
@@ -89,7 +93,7 @@ class Player(GameObject):
|
||||
def fire(self, screen):
|
||||
projectile_width = 6
|
||||
projectile_height = 10
|
||||
shot = Projectile(self.name, self.pos_x+(self.width/2)-(projectile_width/2), self.pos_y-projectile_height, projectile_width, projectile_height, screen, 10)
|
||||
shot = Projectile(self.name, self.pos_x+(self.width/2)-(projectile_width/2), self.pos_y-projectile_height, projectile_width, projectile_height, screen, 8)
|
||||
|
||||
def firecontrol(self, screen):
|
||||
if(len(Projectile.shots) > 0):
|
||||
|
||||
Reference in New Issue
Block a user