Add pause.

This commit is contained in:
Thomas Gideon 2017-08-08 12:51:29 -04:00
parent a5314ca0c0
commit 0461547b8f

View file

@ -23,6 +23,7 @@ pub struct Game {
player: Hero, player: Hero,
stars: Vec<Star>, stars: Vec<Star>,
diag: bool, diag: bool,
pause: bool,
victory: bool, victory: bool,
loss: bool, loss: bool,
} }
@ -40,13 +41,14 @@ impl Game {
player: player, player: player,
stars: stars, stars: stars,
diag: false, diag: false,
pause: false,
victory: false, victory: false,
loss: false, loss: false,
} }
} }
pub fn on_update(&mut self, e: &Input, upd: UpdateArgs, w: &PistonWindow) { pub fn on_update(&mut self, e: &Input, upd: UpdateArgs, w: &PistonWindow) {
if self.victory || self.loss { if self.pause || self.victory || self.loss {
return; return;
} }
self.scene.event(e); self.scene.event(e);
@ -168,6 +170,9 @@ impl Game {
Button::Keyboard(Key::H) => { Button::Keyboard(Key::H) => {
self.diag = !self.diag; self.diag = !self.diag;
} }
Button::Keyboard(Key::P) => {
self.pause = !self.pause;
}
_ => {} _ => {}
} }
} }