Add start of ship editing

This commit is contained in:
asraelite 2018-03-04 16:49:42 +00:00
parent d85338d9f2
commit b88c0eb358
18 changed files with 288 additions and 100 deletions

View file

@ -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();
}
}