diff --git a/src/game/gameScene.js b/src/game/gameScene.js index 3c95b30..006e226 100644 --- a/src/game/gameScene.js +++ b/src/game/gameScene.js @@ -6,6 +6,11 @@ import { dialog } from "../stores/dialog.js"; const textureWidth = 100; +var stepNum; +steps.subscribe(t => { + stepNum = t; +}); + export class GameScene extends Phaser.Scene { constructor(map) { super({ @@ -61,6 +66,7 @@ export class GameScene extends Phaser.Scene { createMap() { console.log(this.map); + steps.set(this.map.steps); this.container = this.add.container(); this.container.width = this.map.size.x * this.map.px + this.map.offset.x * 2; this.container.height = this.map.size.y * this.map.px + this.map.offset.y * 2; @@ -196,6 +202,11 @@ export class GameScene extends Phaser.Scene { if(this.items[toX + moveX][toY + moveY] && this.items[toX + moveX][toY + moveY].type !== "wind") return; this.move(toX, toY, toX + moveX, toY + moveY); } + if(stepNum <= 0) { + this.unload(); + this.createMap(); + return; + } this.canMove = false; if(!fromWind) { steps.update(t => --t); diff --git a/src/game/index.js b/src/game/index.js index 2412f4f..48b9a26 100644 --- a/src/game/index.js +++ b/src/game/index.js @@ -50,7 +50,7 @@ export function setMap(newmap) { mapname = newmap; map = maps[mapname]; if(gs) { - // gs.unload(); + gs.unload(); gs.map = map; gs.createMap(); }