arrow key support
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -142,15 +142,19 @@ fn levelload(
|
|||||||
fn gameloop(keyb: Res<ButtonInput<KeyCode>>, mut player: Single<(&mut Player, &mut Transform)>) {
|
fn gameloop(keyb: Res<ButtonInput<KeyCode>>, mut player: Single<(&mut Player, &mut Transform)>) {
|
||||||
let mut dir = IVec2::ZERO;
|
let mut dir = IVec2::ZERO;
|
||||||
|
|
||||||
if keyb.pressed(KeyCode::KeyA) {
|
if keyb.pressed(KeyCode::KeyA) || keyb.pressed(KeyCode::ArrowLeft) {
|
||||||
dir.x = -1;
|
dir.x += -1;
|
||||||
} else if keyb.pressed(KeyCode::KeyD) {
|
|
||||||
dir.x = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyb.pressed(KeyCode::KeyW) {
|
if keyb.pressed(KeyCode::KeyD) || keyb.pressed(KeyCode::ArrowRight) {
|
||||||
dir.y = 1;
|
dir.x += 1;
|
||||||
} else if keyb.pressed(KeyCode::KeyS) {
|
}
|
||||||
|
|
||||||
|
if keyb.pressed(KeyCode::KeyW) || keyb.pressed(KeyCode::ArrowUp) {
|
||||||
|
dir.y += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if keyb.pressed(KeyCode::KeyS) || keyb.pressed(KeyCode::ArrowDown) {
|
||||||
dir.y = -1;
|
dir.y = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user