+ 1
shooting game project in python.. can anyone help in debugging
class Enemy: name = "" lives = 0 def __init__(self, name, lives): self.name = name self.lives = lives def hit(self): self.lives -= 1 if self.lives <= 0: print(self.name + ' killed') else: print(self.name + ' has '+ str(self.lives) + ' lives') class Monster: def __init__(self): super().__init__('Monster', 3) class Alien: def __init__(self): super().__init__('Alien', 5) m = Monster() a = Alien() while True: x = input() if x == 'exit': break
2 Respuestas
+ 7
1. Monster and Alien classes should be inherited from the Enemy class, so that `super()` returns it.
2. I believe that you did not do it yet or there is not enough space for it to be visible, but are is mechanics on "laser" and "gun" missing.
0
the while loop seems to be problem, not able to call the hit function in it\: