mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-23 05:47:33 +08:00
update framework
This commit is contained in:
+12
-28
@@ -1,31 +1,15 @@
|
||||
import App from '../src/app.js';
|
||||
import App from './app.js';
|
||||
import Life from './modules/life.js';
|
||||
|
||||
globalThis.$$eventMap = new Map();
|
||||
globalThis.$$event = (tag, data) => {
|
||||
const listener = $$eventMap.get(tag);
|
||||
if(listener) listener.forEach(fn=>fn(data));
|
||||
}
|
||||
globalThis.$$on = (tag, fn) => {
|
||||
let listener = $$eventMap.get(tag);
|
||||
if(!listener) {
|
||||
listener = new Set();
|
||||
$$eventMap.set(tag, listener);
|
||||
}
|
||||
listener.add(fn);
|
||||
}
|
||||
globalThis.$$off = (tag, fn) => {
|
||||
const listener = $$eventMap.get(tag);
|
||||
if(listener) listener.delete(fn);
|
||||
}
|
||||
const core = new Life();
|
||||
const game = new App();
|
||||
globalThis.core = core;
|
||||
globalThis.game = game;
|
||||
|
||||
globalThis.json = async fileName => await (await fetch(`../data/${fileName}.json`)).json();
|
||||
const query = {};
|
||||
location.search.substr(1).split('&').forEach(item => {
|
||||
const parts = item.split('=');
|
||||
query[parts[0]] = parts[1];
|
||||
});
|
||||
|
||||
// Pssst, I've created a github package - https://github.com/brookesb91/dismissible
|
||||
globalThis.hideBanners = (e) => {
|
||||
document
|
||||
.querySelectorAll(".banner.visible")
|
||||
.forEach((b) => b.classList.remove("visible"));
|
||||
};
|
||||
|
||||
const app = new App();
|
||||
app.initial();
|
||||
game.start(query.lang);
|
||||
|
||||
Reference in New Issue
Block a user