Skip to content

Instantly share code, notes, and snippets.

@fadhilsaheer
Created January 11, 2022 02:09
Show Gist options
  • Save fadhilsaheer/ef9bf9a860e61fdcc3699cec25071ce9 to your computer and use it in GitHub Desktop.
Save fadhilsaheer/ef9bf9a860e61fdcc3699cec25071ce9 to your computer and use it in GitHub Desktop.
Google dino game over script, where user get highscore without getting knocked

Original Game Over Script

function() {
    this.playSound(this.soundFx.HIT);
    vibrate(200);

    this.stop();
    this.crashed = true;
    this.distanceMeter.achievement = false;

    this.tRex.update(100, Trex.status.CRASHED);

    // Game over panel.
    if (!this.gameOverPanel) {
      this.gameOverPanel = new GameOverPanel(this.canvas,
          this.spriteDef.TEXT_SPRITE, this.spriteDef.RESTART,
          this.dimensions);
    } else {
      this.gameOverPanel.draw();
    }

    // Update the high score.
    if (this.distanceRan > this.highestScore) {
      this.highestScore = Math.ceil(this.distanceRan);
      this.distanceMeter.setHighScore(this.highestScore);
    }

    // Reset the time clock.
    this.time = getTimeStamp();
  }

Modified Game Over Script (Hack Script)

function () {
    if (this.distanceRan > this.highestScore) {
      this.highestScore = Math.ceil(this.distanceRan);
      this.distanceMeter.setHighScore(this.highestScore);
    }
    
    this.time = getTimeStamp();
}

use Runner.prototype.gameOver for assigning script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment