Add rotation view and path prediction toggles
This commit is contained in:
parent
ce6a707526
commit
5b861cc341
12 changed files with 195 additions and 19 deletions
|
@ -11,6 +11,8 @@ export const mapping = {
|
|||
right: 'KeyD',
|
||||
exitEdit: 'Escape',
|
||||
inventory: 'KeyE',
|
||||
cycleRotation: 'KeyC',
|
||||
toggleTrace: 'KeyT'
|
||||
};
|
||||
|
||||
let held, pressed;
|
||||
|
@ -49,6 +51,15 @@ function tickPlaying() {
|
|||
state.inventory = !state.inventory;
|
||||
}
|
||||
|
||||
if (pressed[mapping.cycleRotation]) {
|
||||
events.cycleRotationMode();
|
||||
}
|
||||
|
||||
if (pressed[mapping.toggleTrace]) {
|
||||
events.toggleTrace();
|
||||
}
|
||||
|
||||
// For debugging.
|
||||
if (pressed['KeyR']) events.startGame();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,23 @@ import * as edit from './edit.mjs';
|
|||
|
||||
export let shipLanded = false;
|
||||
|
||||
let notification;
|
||||
let notLife = 0;
|
||||
|
||||
function notify(message) {
|
||||
notification.text = message;
|
||||
notLife = 60;
|
||||
}
|
||||
|
||||
export function tick() {
|
||||
if (notLife-- <= 0)
|
||||
notification.text = '';
|
||||
}
|
||||
|
||||
export function setNotificationElement(el) {
|
||||
notification = el;
|
||||
}
|
||||
|
||||
export function startGame() {
|
||||
game.changeView('game');
|
||||
graphics.perspective.focusPlayer();
|
||||
|
@ -33,6 +50,21 @@ export function toggleEdit() {
|
|||
edit.init();
|
||||
}
|
||||
|
||||
export function toggleTrace() {
|
||||
let trace = graphics.toggleTrace();
|
||||
notify('Path prediction: ' + (trace ? 'on' : 'off'));
|
||||
}
|
||||
|
||||
export function cycleRotationMode() {
|
||||
let message = {
|
||||
parent: 'planet',
|
||||
local: 'ship',
|
||||
universe: 'universe'
|
||||
}[graphics.cycleRotationMode()];
|
||||
|
||||
notify('Rotation view: ' + message);
|
||||
}
|
||||
|
||||
export function endEditing() {
|
||||
let {valid, reason} = edit.end();
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ export function changeView(view) {
|
|||
}
|
||||
|
||||
function tick() {
|
||||
events.tick();
|
||||
|
||||
if (state.view == 'game') {
|
||||
world.tick();
|
||||
control.tick();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue