Add item markers
This commit is contained in:
parent
b27bd7bba2
commit
3eb74e44aa
8 changed files with 41 additions and 12 deletions
|
@ -12,7 +12,8 @@ export const mapping = {
|
|||
exitEdit: 'Escape',
|
||||
inventory: 'KeyE',
|
||||
cycleRotation: 'KeyC',
|
||||
toggleTrace: 'KeyT'
|
||||
toggleTrace: 'KeyT',
|
||||
toggleMarkers: 'KeyR'
|
||||
};
|
||||
|
||||
let held, pressed;
|
||||
|
@ -59,14 +60,16 @@ function tickPlaying() {
|
|||
events.toggleTrace();
|
||||
}
|
||||
|
||||
if (pressed[mapping.toggleMarkers]) {
|
||||
events.toggleMarkers();
|
||||
}
|
||||
|
||||
// For debugging.
|
||||
if (pressed['KeyR']) events.startGame();
|
||||
if (pressed['KeyZ']) events.startGame();
|
||||
}
|
||||
|
||||
function tickEditing() {
|
||||
if (pressed[mapping.exitEdit]) {
|
||||
events.endEditing();
|
||||
}
|
||||
|
||||
if (pressed['KeyX']) throw new Error();
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ let notLife = 0;
|
|||
|
||||
let landedPlanets = new Set();
|
||||
|
||||
function notify(message) {
|
||||
function notify(message, time = 80) {
|
||||
if (notification === null) return;
|
||||
notification.text = message;
|
||||
notLife = 80;
|
||||
notLife = time;
|
||||
}
|
||||
|
||||
export function tick() {
|
||||
|
@ -47,6 +47,7 @@ export function landShip(planet) {
|
|||
function newPlanet(planet) {
|
||||
let value = (planet.radius + 30) | 0;
|
||||
landedPlanets.add(planet);
|
||||
audio.play('newPlanet');
|
||||
score += value;
|
||||
notify('Landed on new planet: +' + value);
|
||||
}
|
||||
|
@ -71,6 +72,11 @@ export function toggleTrace() {
|
|||
notify('Path prediction: ' + (trace ? 'on' : 'off'));
|
||||
}
|
||||
|
||||
export function toggleMarkers() {
|
||||
let markers = graphics.toggleMarkers();
|
||||
notify('Item markers: ' + (markers ? 'on' : 'off'));
|
||||
}
|
||||
|
||||
export function cycleRotationMode() {
|
||||
let message = {
|
||||
parent: 'planet',
|
||||
|
@ -105,7 +111,7 @@ export function tossItem() {
|
|||
particle.createItemToss(world.playerShip);
|
||||
}
|
||||
|
||||
export function collectItem(type, id) {
|
||||
export function collectItem(type, id, name) {
|
||||
if (type === 'fuelcan') {
|
||||
world.playerShip.addFuel(consts.FUEL_CAN_AMOUNT);
|
||||
audio.play('fuelPickup');
|
||||
|
@ -116,7 +122,7 @@ export function collectItem(type, id) {
|
|||
inventory.addItem(type, id);
|
||||
audio.play('itemPickup');
|
||||
score += 20;
|
||||
notify('Collected module: +20');
|
||||
notify(`Collected "${name}" module: +20`, 150);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export async function init() {
|
|||
gui.init();
|
||||
input.init();
|
||||
|
||||
//events.startGame();
|
||||
events.startGame();
|
||||
|
||||
//tick(); return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue