mirror of
https://github.com/danbulant/heaventaker
synced 2026-07-05 19:20:35 +00:00
restart on failure
This commit is contained in:
parent
235c69d18f
commit
05c41d003b
2 changed files with 12 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export function setMap(newmap) {
|
|||
mapname = newmap;
|
||||
map = maps[mapname];
|
||||
if(gs) {
|
||||
// gs.unload();
|
||||
gs.unload();
|
||||
gs.map = map;
|
||||
gs.createMap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue