Skip to content

Commit 6865c2a

Browse files
Restart the game on the menu screen
1 parent 47ddc36 commit 6865c2a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl EventHandler for MyGame {
119119

120120
fn key_down_event(
121121
&mut self,
122-
_ctx: &mut Context,
122+
ctx: &mut Context,
123123
keycode: KeyCode,
124124
_keymod: KeyMods,
125125
_repeat: bool,
@@ -136,6 +136,14 @@ impl EventHandler for MyGame {
136136
let change = self.game_screen.lock().unwrap().key_press(keycode);
137137

138138
if let Some(s) = change {
139+
match s {
140+
Screen::Menu => {
141+
self.game_screen = game::Game::create(ctx);
142+
}
143+
144+
_ => (),
145+
}
146+
139147
self.screen = s;
140148
}
141149
}

0 commit comments

Comments
 (0)