Skip to content

Commit 82ef64c

Browse files
committed
Guard turns on gate drop
1 parent ddc5c98 commit 82ef64c

File tree

6 files changed

+55
-38
lines changed

6 files changed

+55
-38
lines changed

package-lock.json

Lines changed: 35 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"homepage": "https://github.com/oklemenz/PrinceJS#readme",
2828
"devDependencies": {
29-
"eslint": "^8.52.0",
29+
"eslint": "^8.53.0",
3030
"eslint-config": "^0.3.0",
3131
"eslint-config-prettier": "^9.0.0",
3232
"http-server": "^14.1.1",

src/Game.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,19 @@ PrinceJS.Game.prototype = {
753753
}
754754
},
755755

756+
checkGateFastDropped: function (gate) {
757+
for (let i = 0; i < this.enemies.length; i++) {
758+
let enemy = this.enemies[i];
759+
if (enemy.room === gate.room) {
760+
if (enemy.faceL() && enemy.charBlockX <= gate.roomX) {
761+
enemy.turn();
762+
} else if (enemy.faceR() && enemy.charBlockX >= gate.roomX) {
763+
enemy.turn();
764+
}
765+
}
766+
}
767+
},
768+
756769
recheckCurrentRoom: function () {
757770
this.checkForOpponent(this.currentCameraRoom);
758771
},

src/Kid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ PrinceJS.Kid.prototype.floatFall = function () {
17251725
}
17261726
this.inFloat = true;
17271727
this.game.sound.play("Float");
1728-
const handle = PrinceJS.Utils.delayedCancelable(() => {
1728+
let handle = PrinceJS.Utils.delayedCancelable(() => {
17291729
this.inFloat = false;
17301730
this.inFloatTimeoutCancel = null;
17311731
this.fallingBlocks = 0;

src/LevelBuilder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ PrinceJS.LevelBuilder.prototype = {
173173
case PrinceJS.Level.TILE_POTION:
174174
tile = new PrinceJS.Tile.Potion(this.game, t.modifier, this.type);
175175
if (tile.isSpecial) {
176-
const specialTile = this.getTileObjectAt(0, 0, 8);
176+
let specialTile = this.getTileObjectAt(0, 0, 8);
177177
if (specialTile) {
178178
tile.specialModifier = specialTile.modifier;
179179
tile.onDrank.add(this.delegate.fireEvent, this.delegate);
@@ -230,6 +230,7 @@ PrinceJS.LevelBuilder.prototype = {
230230

231231
case PrinceJS.Level.TILE_GATE:
232232
tile = new PrinceJS.Tile.Gate(this.game, t.modifier, this.type);
233+
tile.onFastDrop.add(this.delegate.checkGateFastDropped, this.delegate);
233234
if (t.mute === false) {
234235
tile.setCanMute(false);
235236
}

src/tiles/Gate.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
PrinceJS.Tile.Gate = function (game, modifier, type) {
44
PrinceJS.Tile.Base.call(this, game, PrinceJS.Level.TILE_GATE, modifier, type);
55

6+
this.onFastDrop = new Phaser.Signal();
7+
68
this.posY = -modifier * 46;
79

810
this.tileChildBack = this.game.make.sprite(0, 0, this.key, this.key + "_gate");
@@ -128,6 +130,7 @@ PrinceJS.Tile.Gate.prototype.update = function () {
128130
this.state = PrinceJS.Tile.Gate.STATE_CLOSED;
129131
if (closeSound) {
130132
this.game.sound.play("GateReachesBottomClang");
133+
this.onFastDrop.dispatch(this);
131134
}
132135
}
133136
break;

0 commit comments

Comments
 (0)