mirror of
https://github.com/danbulant/heaventaker
synced 2026-07-10 21:50:47 +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;
|
const textureWidth = 100;
|
||||||
|
|
||||||
|
var stepNum;
|
||||||
|
steps.subscribe(t => {
|
||||||
|
stepNum = t;
|
||||||
|
});
|
||||||
|
|
||||||
export class GameScene extends Phaser.Scene {
|
export class GameScene extends Phaser.Scene {
|
||||||
constructor(map) {
|
constructor(map) {
|
||||||
super({
|
super({
|
||||||
|
|
@ -61,6 +66,7 @@ export class GameScene extends Phaser.Scene {
|
||||||
createMap() {
|
createMap() {
|
||||||
console.log(this.map);
|
console.log(this.map);
|
||||||
|
|
||||||
|
steps.set(this.map.steps);
|
||||||
this.container = this.add.container();
|
this.container = this.add.container();
|
||||||
this.container.width = this.map.size.x * this.map.px + this.map.offset.x * 2;
|
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;
|
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;
|
if(this.items[toX + moveX][toY + moveY] && this.items[toX + moveX][toY + moveY].type !== "wind") return;
|
||||||
this.move(toX, toY, toX + moveX, toY + moveY);
|
this.move(toX, toY, toX + moveX, toY + moveY);
|
||||||
}
|
}
|
||||||
|
if(stepNum <= 0) {
|
||||||
|
this.unload();
|
||||||
|
this.createMap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.canMove = false;
|
this.canMove = false;
|
||||||
if(!fromWind) {
|
if(!fromWind) {
|
||||||
steps.update(t => --t);
|
steps.update(t => --t);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export function setMap(newmap) {
|
||||||
mapname = newmap;
|
mapname = newmap;
|
||||||
map = maps[mapname];
|
map = maps[mapname];
|
||||||
if(gs) {
|
if(gs) {
|
||||||
// gs.unload();
|
gs.unload();
|
||||||
gs.map = map;
|
gs.map = map;
|
||||||
gs.createMap();
|
gs.createMap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue