Add ship movement
This commit is contained in:
parent
09b3df649c
commit
4959519f39
15 changed files with 278 additions and 77 deletions
25
js/game/control.mjs
Normal file
25
js/game/control.mjs
Normal 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 });
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue