Add score and fuel overlay

This commit is contained in:
asraelite 2018-03-07 01:23:35 +00:00
parent 27c6a8bcd0
commit 4f8fd6e1af
13 changed files with 130 additions and 37 deletions

View file

@ -1,21 +1,23 @@
import * as game from './index.mjs';
import * as graphics from '../graphics/index.mjs';
import * as world from '../world/index.mjs';
import * as player from './player.mjs';
import * as inventory from './inventory.mjs';
import * as particle from '../world/particle.mjs';
import * as edit from './edit.mjs';
import * as audio from './audio.mjs';
export let shipLanded = false;
export let score = 0;
let notification = null;
let notLife = 0;
let landedPlanets = new Set();
function notify(message) {
if (notification === null) return;
notification.text = message;
notLife = 60;
notLife = 80;
}
export function tick() {
@ -33,11 +35,21 @@ export function startGame() {
graphics.perspective.focusPlayer();
}
export function landShip() {
export function landShip(planet) {
shipLanded = true;
if (!landedPlanets.has(planet)) {
newPlanet(planet);
}
game.state.landed = true;
}
function newPlanet(planet) {
let value = (planet.radius + 30) | 0;
landedPlanets.add(planet);
score += value;
notify('Landed on new planet: +' + value);
}
export function launchShip() {
shipLanded = false;
game.state.landed = false;
@ -95,5 +107,7 @@ export function tossItem() {
export function collectItem(type, id) {
inventory.addItem(type, id);
audio.play('itemPickup');
score += 20;
notify('Collected module: +20');
return true;
}