Newer
Older
open-logistic-tycoon / game / Game.js
class Game {
	constructor() {
		console.log("Init Game"); 
		this.initMainMenu();
	}

	initMainMenu() {
		app.kernel.boot.renderer.addRenderFunc("Menu", () => {
			const btn = document.createElement("BUTTON");
			btn.classList.add("btn");
			btn.classList.add("btn-secondary");
			btn.innerHTML = "New Game";
			btn.addEventListener("click", e => {
				alert("STARTING NEW GAME");
			});

			return { btn: btn };
		});

		app.kernel.boot.renderer.addRenderFunc("Menu", () => {
			const btn = document.createElement("BUTTON");
			btn.classList.add("btn");
			btn.classList.add("btn-secondary");
			btn.innerHTML = "Load Game";
			btn.addEventListener("click", e => {
				alert("Loading GAME");
			});

			return { btn: btn };
		});

		app.kernel.boot.renderer.addRenderFunc("Menu", () => {
			const btn = document.createElement("BUTTON");
			btn.classList.add("btn");
			btn.classList.add("btn-secondary");
			btn.innerHTML = "Settings";
			btn.addEventListener("click", e => {
				alert("OPEN SETTINGS");
			});

			return { btn: btn };
		});

		app.kernel.boot.renderer.addRenderFunc("Menu", () => {
			const btn = document.createElement("BUTTON");
			btn.classList.add("btn");
			btn.classList.add("btn-secondary");
			btn.innerHTML = "Exit";
			btn.addEventListener("click", e => {
				alert("EXIT");
			});

			return { btn: btn };
		});

		app.kernel.boot.renderer.renderMenu();
	}
}