Skip to content
Snippets Groups Projects
Commit c892e366 authored by pumapaul's avatar pumapaul
Browse files

Fix infinite enemy turn with a dirty hack

parent 667c68a7
No related branches found
No related tags found
No related merge requests found
......@@ -250,8 +250,13 @@ impl GameState {
fn move_enemy(&mut self, id: usize, position: Point) {
let mut target_position = GameState::randomize_target_position(position);
let mut hacky_while_counter = 0;
while !self.validate_target_position(target_position) {
target_position = GameState::randomize_target_position(position);
hacky_while_counter += 1;
if hacky_while_counter > 20 {
return;
}
}
self.current_run.level.move_enemy_to(id, position, target_position);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment