+ 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

1st Jan 2022, 5:42 AM
Debashish Das
Debashish Das - avatar
2 Answers
+ 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.
1st Jan 2022, 5:58 AM
#0009e7 [get]
#0009e7 [get] - avatar
0
the while loop seems to be problem, not able to call the hit function in it\:
1st Jan 2022, 6:00 AM
Debashish Das
Debashish Das - avatar