Skip to content

Commit

Permalink
fix capy runner
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev committed Dec 13, 2024
1 parent ad7524a commit e75f50c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions nextjs/csp/policies/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function app(): CspDev.DirectiveDescriptor {
// hash of ColorModeScript: system + dark
'\'sha256-e7MRMmTzLsLQvIy1iizO1lXf7VWYoQ6ysj5fuUzvRwE=\'',
'\'sha256-9A7qFFHmxdWjZMQmfzYD2XWaNHLu1ZmQB0Ds4Go764k=\'',
'\'sha256-5+YTmTcBwCYdJ8Jetbr6kyjGp0Ry/H7ptpoun6CrSwQ=\'',
],

'style-src': [
Expand Down
21 changes: 13 additions & 8 deletions public/static/capibara/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
this.images = {};
this.imagesLoaded = 0;

this.highScoreReached = false; // Add this new flag

if (this.isDisabled()) {
this.setupDisabledRunner();
} else {
Expand Down Expand Up @@ -540,19 +542,22 @@
if (!collision) {
this.distanceRan += this.currentSpeed * deltaTime / this.msPerFrame;

if (!this.highScoreReached && this.distanceMeter.getActualDistance(this.distanceRan) >= 1000) {
this.highScoreReached = true;
window.dispatchEvent(new CustomEvent('reachedHighScore', {
detail: { score: this.distanceRan }
}));
}

if (this.currentSpeed < this.config.MAX_SPEED) {
this.currentSpeed += this.config.ACCELERATION;
}
} else {
this.gameOver();
}

// var playAchievementSound = this.distanceMeter.update(deltaTime,
// Math.ceil(this.distanceRan));

// if (playAchievementSound) {
// this.playSound(this.soundFx.SCORE);
// }
this.distanceMeter.update(deltaTime,
Math.ceil(this.distanceRan));

// Night mode.
if (this.invertTimer > this.config.INVERT_FADE_DURATION) {
Expand Down Expand Up @@ -1773,6 +1778,7 @@
this.midair = false;
this.speedDrop = false;
this.jumpCount = 0;
this.highScoreReached = false;
}
};

Expand Down Expand Up @@ -1944,7 +1950,6 @@
*/
update: function (deltaTime, distance) {
var paint = true;
// var playSound = false;

if (!this.acheivement) {
distance = this.getActualDistance(distance);
Expand Down Expand Up @@ -2640,4 +2645,4 @@
};
})();

new Runner('.interstitial-wrapper');
new Runner('.interstitial-wrapper');
16 changes: 10 additions & 6 deletions ui/games/CapybaraRunner.tsx

Large diffs are not rendered by default.

0 comments on commit e75f50c

Please sign in to comment.