Bug fixes

This commit is contained in:
asraelite 2018-03-06 00:32:29 +00:00
parent 69fee5e73d
commit ce6a707526
5 changed files with 30 additions and 9 deletions

View file

@ -48,6 +48,8 @@ function tickPlaying() {
if (pressed[mapping.inventory]) {
state.inventory = !state.inventory;
}
if (pressed['KeyR']) events.startGame();
}
function tickEditing() {

View file

@ -1,3 +1,4 @@
import {state} from './index.mjs';
import {modules} from '../data.mjs';
import {images as assets} from '../assets.mjs';
import * as events from './events.mjs';
@ -5,6 +6,8 @@ import * as events from './events.mjs';
export const items = new Map();
export let currentItem = null;
let onupdate = () => {};
export function init() {
items.clear();
}
@ -20,6 +23,7 @@ export function addItem(type, id) {
if (!items.has(mapId)) items.set(mapId, new Tile(type, id));
let tile = items.get(mapId);
tile.increase();
update();
}
export function removeItem(type, id) {
@ -31,11 +35,22 @@ export function removeItem(type, id) {
items.delete(mapId);
currentItem = null;
}
events.tossItem();
if (!state.editing)
events.tossItem();
update();
}
export function selectItem(type, id) {
currentItem = items.get(toId(type, id));
update();
}
export function setOnupdate(func) {
onupdate = func;
}
function update() {
onupdate();
}
function toId(type, id) {