Open Starlight-30036225 opened 6 months ago
`` def defend(self): for bullet in game.bolts:
if bullet.y >= self.top and bullet.y < self.bottom and abs(bullet.x - self.x) < 200:
if bullet.direction_x == sign(self.x - bullet.x):
self.Pmove(sign(bullet.x - self.x))
self.fire()
break
``
This works. the player will only destroy bullets currently attacking it
I want to give a chance to also jump, if the player has no bullets then definately jump
The player jumps and shoots, im not sure how to stop it from doing both other than a defence cooldown. Which im not a huge fan of. But itll do for now
I want the player to be able to defend itself from incoming bullets from the robots. For this I will need to check if any bullets are close, and if they are facing the player. Then either fire or jump to avoid it (I would like this to be random for variation.