require('MainMenu'); require('World'); class Game { constructor() { this.container = null; this.theater = null; this.canvas = null; this.system = null; this.state = "mainmenu"; this.stage = null; this.stages = []; } init(system, container, canvas) { this.system = system; this.container = container; this.canvas = canvas; this.theater = this; this.stages.push(new MainMenu()); this.stages.push(new World()); this.changeStage("mainmenu"); } changeStage(newstage) { if (this.stage != null && this.stage.end) { this.stage.end(); } this.state = newstage; switch (this.state) { case "mainmenu": this.stage = this.stages[0]; break; case "world": this.stage = this.stages[1]; break; } this.stage.init(this.system, this.canvas); } updateDelta(delta, canvas) { this.stage.updateDelta(delta, canvas); } draw(context) { this.stage.draw(context); } handleResize(canvas) { if (!this.stage.hasOwnProperty("handleResize")) { return; } this.stage.handleResize(canvas); } };