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

Fix player being able to take actions after death

parent faa96693
No related branches found
No related tags found
No related merge requests found
......@@ -92,19 +92,20 @@ impl GameState {
fn handle_user_turn(&mut self, ctx: &mut Context) -> bool {
let key = GameState::get_pressed_key(ctx);
let is_player_alive = self.current_run.player.current_hp > 0;
return match key {
Key::CapsLock => false,
Key::N => self.create_new_run(),
Key::W | Key::A | Key::S | Key::D | Key::Down | Key::Up | Key::Right | Key::Left => GameState::handle_user_movement(self, key),
Key::Space => true,
Key::N => !is_player_alive && self.create_new_run(),
Key::W | Key::A | Key::S | Key::D | Key::Down | Key::Up | Key::Right | Key::Left =>
is_player_alive && self.handle_user_movement(key),
Key::Space => is_player_alive,
_ => false
};
}
fn create_new_run(&mut self) -> bool {
if self.current_run.player.current_hp == 0 {
self.current_run = Run::new();
}
self.current_run = Run::new();
false
}
......
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