Add picking random target for A* algorithm
When user clicks "u" key target is being picked.
This commit is contained in:
parent
ab1b4e9efc
commit
b8abacd4cc
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user