From 2a0c495e22b3618942587210083c24ec5e82b56f Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 12 Aug 2024 08:45:53 +0200 Subject: [PATCH] Fixed Player2 gamecrash on fire --- GameObject.py | 6 +++--- test.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/GameObject.py b/GameObject.py index d152a11..0cfd4a7 100644 --- a/GameObject.py +++ b/GameObject.py @@ -78,12 +78,12 @@ class Player(GameObject): shot = Projectile(self.name, self.pos_x+(self.width/2),self.pos_y-self.height,5,10, screen) def firecontrol(self, screen): - if(len(Projectile.shots) >0): + if(len(Projectile.shots) > 0): for objects in Projectile.shots: objects:dict for key, object in objects.items(): object:Projectile - if(key == "Player"): + if(key == "Player"or key == "Player2"): object.animate("UP") #print("Playerschuss!") @@ -122,7 +122,7 @@ class Enemy(GameObject): super().__init__(name, pos_x, pos_y, width, height, image) def fire(self, screen): - print("Schieße!!!!") + #print("Schieße!!!!") shot = Projectile("Enemy", self.pos_x+(self.width/2),self.pos_y+self.height,5,10, screen) self.shots_fired.append(shot) diff --git a/test.py b/test.py index ea6269c..64f603c 100644 --- a/test.py +++ b/test.py @@ -88,6 +88,7 @@ while(gamestate): for key, projectile in projectiles.items(): projectile:GameObject.Projectile #Check if player hits an enemy delete it + print(projectile.rect) for enemy in spawned_enemys: enemy:GameObject.Enemy if(pygame.Rect.colliderect(projectile.rect, enemy.rect)):