Skip to content

Commit

Permalink
Grab wait to climb up
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz committed May 11, 2022
1 parent 5f5265c commit d02112c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Kid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PrinceJS.Kid = function (game, level, location, direction, room) {
this.checkFloorStepFall = false;
this.backwardsFall = 1;
this.ledgeSwing = 0;
this.grabWait = false;

this.cursors = this.game.input.keyboard.createCursorKeys();
this.shiftKey = this.game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
Expand Down Expand Up @@ -396,7 +397,7 @@ PrinceJS.Kid.prototype.updateBehaviour = function () {
this.startFall();
}
}
if (this.keyU()) {
if (this.keyU() && !this.grabWait) {
return this.climbup();
}
if (!this.keyS()) {
Expand All @@ -409,7 +410,7 @@ PrinceJS.Kid.prototype.updateBehaviour = function () {

case "hangstraight":
this.charRepeat = false;
if (this.keyU()) {
if (this.keyU() && !this.grabWait) {
return this.climbup();
}
if (!this.keyS()) {
Expand Down Expand Up @@ -589,6 +590,11 @@ PrinceJS.Kid.prototype.grab = function (x) {
if (tile.element === PrinceJS.Level.TILE_LOOSE_BOARD) {
tile.shake(true);
}

this.grabWait = true;
PrinceJS.Utils.delayed(() => {
this.grabWait = false;
}, 500);
};

PrinceJS.Kid.prototype.checkBarrier = function () {
Expand Down

0 comments on commit d02112c

Please sign in to comment.