Add start of ship editing
This commit is contained in:
parent
d85338d9f2
commit
b88c0eb358
18 changed files with 288 additions and 100 deletions
|
@ -1,16 +1,36 @@
|
|||
import * as input from '../input.mjs';
|
||||
import * as events from './events.mjs';
|
||||
import * as player from './player.mjs';
|
||||
import * as graphics from '../graphics/index.mjs';
|
||||
import {state} from './index.mjs';
|
||||
|
||||
export const mapping = {
|
||||
thrust: 'KeyW',
|
||||
left: 'KeyA',
|
||||
right: 'KeyD'
|
||||
right: 'KeyD',
|
||||
exitEdit: 'Escape'
|
||||
};
|
||||
|
||||
export function tick() {
|
||||
let held = input.keyCode.held;
|
||||
let pressed = input.keyCode.pressed;
|
||||
let held, pressed;
|
||||
|
||||
export function tick() {
|
||||
held = input.keyCode.held;
|
||||
pressed = input.keyCode.pressed;
|
||||
|
||||
if (state.editing) {
|
||||
tickEditing();
|
||||
} else if (state.playing) {
|
||||
tickPlaying();
|
||||
}
|
||||
|
||||
if (!state.editing) {
|
||||
if (input.mouse.scroll !== 0) {
|
||||
graphics.changeZoom(-input.mouse.scroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tickPlaying() {
|
||||
if (held[mapping.thrust]) {
|
||||
player.ship.applyThrust({ forward: 1 });
|
||||
}
|
||||
|
@ -23,3 +43,9 @@ export function tick() {
|
|||
player.ship.applyThrust({ turnRight: 1 });
|
||||
}
|
||||
}
|
||||
|
||||
function tickEditing() {
|
||||
if (held[mapping.exitEdit]) {
|
||||
events.endEditing();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue