diff --git a/src/main.rs b/src/main.rs index e8710e1..eaae9d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,6 +41,10 @@ fn main() { } for key in keys { + let state = match key { + Scancode::Left | Scancode::Right => 0, + _ => 2, + }; let offset = match key { Scancode::Escape => { game.terminate(); @@ -53,17 +57,9 @@ fn main() { _ => (0, 0), }; - let mut spriteindex = sprites.get(0).unwrap(); - /* + let spriteindex = sprites.get_mut(state).unwrap(); - */ - /*pub const fn unwrap(self) -> T { - match self { - Some(val) => val, - None => panic("called `Option::unwrap()` on a `None` value"), - } - }*/ - //spriteindex.translate(offset); + spriteindex.translate(offset); } ctx.set_background_colour( 129, 201, i);