From 0461547b8fb628481e97b5d64dce6f9705138341 Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Tue, 8 Aug 2017 12:51:29 -0400 Subject: [PATCH] Add pause. --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index adc9c53..22c3ecf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,7 @@ pub struct Game { player: Hero, stars: Vec, diag: bool, + pause: bool, victory: bool, loss: bool, } @@ -40,13 +41,14 @@ impl Game { player: player, stars: stars, diag: false, + pause: false, victory: false, loss: false, } } 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; } self.scene.event(e); @@ -168,6 +170,9 @@ impl Game { Button::Keyboard(Key::H) => { self.diag = !self.diag; } + Button::Keyboard(Key::P) => { + self.pause = !self.pause; + } _ => {} } }