Commit 62eea221 authored by Rahix's avatar Rahix 🦀
Browse files

ingame: Also support arrow keys for movement

Allow players to use the arrows keys as well as WASD for controlling
character movement.
parent c2b7b449
......@@ -113,14 +113,30 @@ impl gamestate::State for InGameState {
.get_mut(&mut self.world, player)
.unwrap();
match event {
gamestate::Event::KeyDown("w") => player_movable.velocity.y = -300.0,
gamestate::Event::KeyUp("w") => player_movable.velocity.y = 0.0,
gamestate::Event::KeyDown("a") => player_movable.velocity.x = -300.0,
gamestate::Event::KeyUp("a") => player_movable.velocity.x = 0.0,
gamestate::Event::KeyDown("s") => player_movable.velocity.y = 300.0,
gamestate::Event::KeyUp("s") => player_movable.velocity.y = 0.0,
gamestate::Event::KeyDown("d") => player_movable.velocity.x = 300.0,
gamestate::Event::KeyUp("d") => player_movable.velocity.x = 0.0,
gamestate::Event::KeyDown("w") | gamestate::Event::KeyDown("ArrowUp") => {
player_movable.velocity.y = -300.0
}
gamestate::Event::KeyUp("w") | gamestate::Event::KeyUp("ArrowUp") => {
player_movable.velocity.y = 0.0
}
gamestate::Event::KeyDown("a") | gamestate::Event::KeyDown("ArrowLeft") => {
player_movable.velocity.x = -300.0
}
gamestate::Event::KeyUp("a") | gamestate::Event::KeyUp("ArrowLeft") => {
player_movable.velocity.x = 0.0
}
gamestate::Event::KeyDown("s") | gamestate::Event::KeyDown("ArrowDown") => {
player_movable.velocity.y = 300.0
}
gamestate::Event::KeyUp("s") | gamestate::Event::KeyUp("ArrowDown") => {
player_movable.velocity.y = 0.0
}
gamestate::Event::KeyDown("d") | gamestate::Event::KeyDown("ArrowRight") => {
player_movable.velocity.x = 300.0
}
gamestate::Event::KeyUp("d") | gamestate::Event::KeyUp("ArrowRight") => {
player_movable.velocity.x = 0.0
}
_ => (),
}
if player_movable.velocity.x != 0.0 || player_movable.velocity.y != 0.0 {
......
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