Add ship movement

This commit is contained in:
asraelite 2018-03-03 15:58:51 +00:00
parent 09b3df649c
commit 4959519f39
15 changed files with 278 additions and 77 deletions

25
js/game/control.mjs Normal file
View file

@ -0,0 +1,25 @@
import * as input from '../input.mjs';
import * as player from './player.mjs';
export const mapping = {
thrust: 'KeyW',
left: 'KeyA',
right: 'KeyD'
};
export function tick() {
let held = input.keyCode.held;
let pressed = input.keyCode.pressed;
if (held[mapping.thrust]) {
player.ship.applyThrust({ forward: 1 });
}
if (held[mapping.left]) {
player.ship.applyThrust({ turnLeft: 1 });
}
if (held[mapping.right]) {
player.ship.applyThrust({ turnRight: 1 });
}
}