mirror of
https://github.com/danbulant/heaventaker
synced 2026-06-22 00:02:00 +00:00
level3 but broken cloud destroying
This commit is contained in:
parent
aaaa87899b
commit
ad68174c60
3 changed files with 77 additions and 27 deletions
|
|
@ -77,7 +77,7 @@ export class GameScene extends Phaser.Scene {
|
|||
}
|
||||
|
||||
calculateScale() {
|
||||
const maxWidth = innerWidth * 0.8 - (document.body.clientHeight / 1080 * 615 * 1.1);
|
||||
const maxWidth = innerWidth * 0.8 - (document.body.clientHeight / 1080 * 615 * 1.15);
|
||||
const maxHeight = innerHeight * 0.8;
|
||||
const targetWidth = this.originalWidth + this.map.offset.x * 2;
|
||||
const targetHeight = this.originalHeight + this.map.offset.y * 2;
|
||||
|
|
@ -130,7 +130,10 @@ export class GameScene extends Phaser.Scene {
|
|||
x = parseInt(x);
|
||||
if(item.type !== "barrier") {
|
||||
var type = item.type;
|
||||
if(type === "angel") type = this.map.sprite;
|
||||
if(type === "angel") {
|
||||
type = this.map.sprite;
|
||||
item.texture = type;
|
||||
}
|
||||
if(this.textures.get(type).frameTotal > 1) {
|
||||
var sprite = this.add.sprite(x * this.map.px, y * this.map.px);
|
||||
item.animated = true;
|
||||
|
|
@ -149,17 +152,17 @@ export class GameScene extends Phaser.Scene {
|
|||
var sprite = this.add.sprite(x * this.map.px, y * this.map.px, type);
|
||||
item.animated = false;
|
||||
}
|
||||
sprite.scale = this.map.px / 100;
|
||||
sprite.setRotation(item.direction * Math.PI / 2);
|
||||
this.grid.add(sprite);
|
||||
item.sprite = sprite;
|
||||
if(type !== item.type) {
|
||||
item.texture = type;
|
||||
}
|
||||
|
||||
if(item.type === "spawn") {
|
||||
/** @type {{ x: number, y: number, hasKey: boolean }} */
|
||||
this.player = item;
|
||||
this.player.x = x;
|
||||
this.player.y = y;
|
||||
this.player.hasKey = false;
|
||||
}
|
||||
if(item.type === "angel") {
|
||||
this.angel = item;
|
||||
|
|
@ -226,36 +229,57 @@ export class GameScene extends Phaser.Scene {
|
|||
return this.isWindActive(x-mov.x, y-mov.y);
|
||||
}
|
||||
|
||||
tryDestroy(toX, toY) {
|
||||
if(this.items[toX][toY].destroyable) {
|
||||
this.items[toX][toY].sprite.alpha = 0;
|
||||
this.items[toX][toY].sprite.destroy();
|
||||
console.log("Destroyed", this.items[toX][toY].sprite);
|
||||
this.items[toX][toY] = null;
|
||||
this.canMove = false;
|
||||
setTimeout(() => {
|
||||
this.canMove = true;
|
||||
}, 400);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
movePlayer(moveX, moveY, fromWind = false) {
|
||||
if(!this.canMove) return;
|
||||
var toX = this.player.x + moveX;
|
||||
var toY = this.player.y + moveY;
|
||||
if(toX > this.map.size.x - 1 || toX < 0 || toY > this.map.size.y - 1 || toY < 0) return;
|
||||
if(this.items[toX][toY]) {
|
||||
if(fromWind) return;
|
||||
if(this.items[toX][toY].type !== "lyre") {
|
||||
if(this.items[toX][toY].destroyable) {
|
||||
this.items[toX][toY].sprite.destroy();
|
||||
this.items[toX][toY] = null;
|
||||
this.canMove = false;
|
||||
setTimeout(() => {
|
||||
this.canMove = true;
|
||||
}, 400);
|
||||
if(this.items[toX][toY].type === "key") {
|
||||
this.items[toX][toY].sprite.destroy();
|
||||
this.items[toX][toY] = null;
|
||||
this.player.hasKey = true;
|
||||
} else if(fromWind) return;
|
||||
else if(this.items[toX][toY].type === "lock") {
|
||||
if(!this.player.hasKey) return;
|
||||
this.items[toX][toY].sprite.destroy();
|
||||
this.items[toX][toY] = null;
|
||||
} else if(this.items[toX][toY].type !== "lyre" && this.tryDestroy(toX, toY)) {
|
||||
steps.update(t => --t);
|
||||
if(stepNum <= 0) {
|
||||
this.unload();
|
||||
this.createMap();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(toX + moveX > this.map.size.x - 1|| toX + moveX < 0 || toY + moveY > this.map.size.y - 1 || toY + moveY < 0) return;
|
||||
if(this.items[toX + moveX][toY + moveY] && this.items[toX + moveX][toY + moveY].type !== "wind") return;
|
||||
if(stepNum <= 0) {
|
||||
this.unload();
|
||||
this.createMap();
|
||||
} else if(this.items[toX][toY].type === "lyre" && !this.items[toX + moveX][toY + moveY]) {
|
||||
if(toX + moveX > this.map.size.x - 1|| toX + moveX < 0 || toY + moveY > this.map.size.y - 1 || toY + moveY < 0) return;
|
||||
if(this.items[toX + moveX][toY + moveY] && this.items[toX + moveX][toY + moveY].type !== "wind") return;
|
||||
if(stepNum <= 0) {
|
||||
this.unload();
|
||||
this.createMap();
|
||||
return;
|
||||
}
|
||||
this.canMove = false;
|
||||
this.move(toX, toY, toX + moveX, toY + moveY, () => {
|
||||
this.canMove = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.canMove = false;
|
||||
this.move(toX, toY, toX + moveX, toY + moveY, () => {
|
||||
this.canMove = true;
|
||||
});
|
||||
return;
|
||||
} else return;
|
||||
}
|
||||
if(stepNum <= 0) {
|
||||
this.unload();
|
||||
|
|
|
|||
|
|
@ -75,11 +75,36 @@ export const maps = {
|
|||
["barrier" , "barrier" , "barrier" , cloud , cloud , cloud , cloud , cloud , cloud , cloud , cloud ],
|
||||
["barrier" , "barrier" , "barrier" , cloud , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "pillar" , cloud ],
|
||||
[cloud , cloud , cloud , cloud , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "pillar" , cloud ],
|
||||
[cloud , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , null , "angel" , cloud ],
|
||||
[cloud , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "barrier" , "angel" , cloud ],
|
||||
[cloud , null , "lyre" , null , null , null , null , "lyre" , null , null , "barrier" ],
|
||||
[null , null , null , "lyre" , "lyre" , null , "lyre" , null , "lyre" , "lyre" , null ],
|
||||
["spawn" , null , "lyre" , null , null , "lyre" , null , "lyre" , null , null , "barrier" ],
|
||||
["barrier" , "barrier" , null , "lyre" , null , null , "lyre" , "barrier" , "barrier" , "barrier" , "barrier" ]
|
||||
]
|
||||
},
|
||||
uziel: {
|
||||
background: "level3",
|
||||
sprite: "uziel",
|
||||
next: "uziel_start",
|
||||
size: {
|
||||
x: 7,
|
||||
y: 8
|
||||
},
|
||||
offset: {
|
||||
x: 0,
|
||||
y: 100
|
||||
},
|
||||
px: 80,
|
||||
steps: 26,
|
||||
map: [
|
||||
["barrier" , "barrier" , "barrier" , "barrier" , "angel" , "barrier" ],
|
||||
[wind(4) , wind(4) , wind(4) , wind(4) , wind(3) , "barrier" ],
|
||||
[null , cloud , null , "lyre" , "lock" , "barrier" ],
|
||||
["barrier" , null , "lyre" , null , null , "barrier" ],
|
||||
["barrier" , cloud , "lyre" , null , null , "barrier" , "barrier" ],
|
||||
["spawn" , null , null , wind(2) , cloud , "lyre" , "key" ],
|
||||
["barrier" , "barrier" , wind(2) , "lyre" ],
|
||||
[null , "barrier" , null , null , null , "barrier" , "barrier" ]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
@ -143,6 +143,7 @@ export const dialog = [{
|
|||
background: "/sprite/backg.webp",
|
||||
character: "Uziel",
|
||||
chapterStart: "uziel",
|
||||
map: "uziel",
|
||||
text: "(she appear out of nowhere and suddenly approaches you.)",
|
||||
buttons: [{
|
||||
text: "oh, you're approaching me? Had you heard of my harem proposal.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue