Commit f2a0c14a authored by Rahix's avatar Rahix 🦀
Browse files

ingame: Add some crude keyboard handling

Just as an example to build on.
parent e9392a74
......@@ -71,7 +71,14 @@ impl gamestate::State for InGameState {
}
fn event(&mut self, event: gamestate::Event) -> gamestate::Transition {
crate::console_log!("event: {:?}", event);
let mut cam = self.resources.get_mut::<resources::Camera>().unwrap();
match event {
gamestate::Event::KeyDown("w") => cam.position.y -= 50.0,
gamestate::Event::KeyDown("a") => cam.position.x -= 50.0,
gamestate::Event::KeyDown("s") => cam.position.y += 50.0,
gamestate::Event::KeyDown("d") => cam.position.x += 50.0,
_ => (),
}
gamestate::Transition::Keep
}
......@@ -82,14 +89,6 @@ impl gamestate::State for InGameState {
rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0);
}
self.schedule.execute(&mut self.world, &mut self.resources);
let done = {
let camera = self.resources.get::<resources::Camera>().unwrap();
camera.position.x > 50.0
};
if done {
gamestate::Transition::Pop
} else {
gamestate::Transition::Loop
}
gamestate::Transition::Loop
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment