Add collectable items

This commit is contained in:
asraelite 2018-03-05 23:53:32 +00:00
parent 826986cdbf
commit 69fee5e73d
10 changed files with 131 additions and 52 deletions

View file

@ -2,6 +2,8 @@ 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';
export let shipLanded = false;
@ -48,3 +50,12 @@ export function invalidTilePlacement() {
export function tilePlacement() {
// TODO: Play some audio.
}
export function tossItem() {
particle.createItemToss(world.playerShip);
}
export function collectItem(type, id) {
inventory.addItem(type, id);
return true;
}

View file

@ -1,5 +1,6 @@
import {modules} from '../data.mjs';
import {images as assets} from '../assets.mjs';
import * as events from './events.mjs';
export const items = new Map();
export let currentItem = null;
@ -30,6 +31,7 @@ export function removeItem(type, id) {
items.delete(mapId);
currentItem = null;
}
events.tossItem();
}
export function selectItem(type, id) {