This commit is contained in:
Llywelwyn 2023-07-11 08:17:18 +01:00
parent 8d04c40389
commit 27d14ac97d
3 changed files with 91 additions and 3 deletions

View file

@ -389,3 +389,34 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
}
MainMenuResult::NoSelection { selected: MainMenuSelection::NewGame }
}
#[derive(PartialEq, Copy, Clone)]
pub enum GameOverResult {
NoSelection,
QuitToMenu,
}
pub fn game_over(ctx: &mut Rltk) -> GameOverResult {
ctx.print_color_centered(15, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "Your journey has ended!");
ctx.print_color_centered(
17,
RGB::named(rltk::WHITE),
RGB::named(rltk::BLACK),
format!("You died after {} turns.", crate::gamelog::get_event_count("Turn")),
);
ctx.print_color_centered(
19,
RGB::named(rltk::MAGENTA),
RGB::named(rltk::BLACK),
"Press Escape to return to the menu.",
);
match ctx.key {
None => GameOverResult::NoSelection,
Some(key) => match key {
VirtualKeyCode::Escape => GameOverResult::QuitToMenu,
_ => GameOverResult::NoSelection,
},
}
}