Skip to content

Commit

Permalink
Guard turns on gate drop
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz committed Nov 6, 2023
1 parent ddc5c98 commit 82ef64c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 38 deletions.
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/oklemenz/PrinceJS#readme",
"devDependencies": {
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"eslint-config": "^0.3.0",
"eslint-config-prettier": "^9.0.0",
"http-server": "^14.1.1",
Expand Down
13 changes: 13 additions & 0 deletions src/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,19 @@ PrinceJS.Game.prototype = {
}
},

checkGateFastDropped: function (gate) {
for (let i = 0; i < this.enemies.length; i++) {
let enemy = this.enemies[i];
if (enemy.room === gate.room) {
if (enemy.faceL() && enemy.charBlockX <= gate.roomX) {
enemy.turn();
} else if (enemy.faceR() && enemy.charBlockX >= gate.roomX) {
enemy.turn();
}
}
}
},

recheckCurrentRoom: function () {
this.checkForOpponent(this.currentCameraRoom);
},
Expand Down
2 changes: 1 addition & 1 deletion src/Kid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ PrinceJS.Kid.prototype.floatFall = function () {
}
this.inFloat = true;
this.game.sound.play("Float");
const handle = PrinceJS.Utils.delayedCancelable(() => {
let handle = PrinceJS.Utils.delayedCancelable(() => {
this.inFloat = false;
this.inFloatTimeoutCancel = null;
this.fallingBlocks = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/LevelBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ PrinceJS.LevelBuilder.prototype = {
case PrinceJS.Level.TILE_POTION:
tile = new PrinceJS.Tile.Potion(this.game, t.modifier, this.type);
if (tile.isSpecial) {
const specialTile = this.getTileObjectAt(0, 0, 8);
let specialTile = this.getTileObjectAt(0, 0, 8);
if (specialTile) {
tile.specialModifier = specialTile.modifier;
tile.onDrank.add(this.delegate.fireEvent, this.delegate);
Expand Down Expand Up @@ -230,6 +230,7 @@ PrinceJS.LevelBuilder.prototype = {

case PrinceJS.Level.TILE_GATE:
tile = new PrinceJS.Tile.Gate(this.game, t.modifier, this.type);
tile.onFastDrop.add(this.delegate.checkGateFastDropped, this.delegate);
if (t.mute === false) {
tile.setCanMute(false);
}
Expand Down
3 changes: 3 additions & 0 deletions src/tiles/Gate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
PrinceJS.Tile.Gate = function (game, modifier, type) {
PrinceJS.Tile.Base.call(this, game, PrinceJS.Level.TILE_GATE, modifier, type);

this.onFastDrop = new Phaser.Signal();

this.posY = -modifier * 46;

this.tileChildBack = this.game.make.sprite(0, 0, this.key, this.key + "_gate");
Expand Down Expand Up @@ -128,6 +130,7 @@ PrinceJS.Tile.Gate.prototype.update = function () {
this.state = PrinceJS.Tile.Gate.STATE_CLOSED;
if (closeSound) {
this.game.sound.play("GateReachesBottomClang");
this.onFastDrop.dispatch(this);
}
}
break;
Expand Down

0 comments on commit 82ef64c

Please sign in to comment.