Add picking random target for A* algorithm

When user clicks "u" key target is being picked.
This commit is contained in:
Michał Czekański 2020-04-26 14:13:27 +02:00
parent ab1b4e9efc
commit b8abacd4cc

View File

@ -91,8 +91,13 @@ class EventManager:
if keys[pygame.K_d]:
self.player.move(Movement.ROTATE_R)
# Pick random target for A* algorithm
if keys[pygame.K_u]:
self.game.movement.gotoToTarget(self.game.map.entities[Random().randint(0, len(self.game.map.entities))])
while True:
try:
self.game.movement.gotoToTarget(self.game.map.entities[Random().randint(0, len(self.game.map.entities))])
break
except Exception:
pass