Commit 36bc8832 authored by Edward Jung's avatar Edward Jung Committed by Commit Bot

chrome://dino - Adjust position of dino following crash whilst ducking

The dino is shifted up when ducking to close the gap. Over many crashes
the dino would shift more and more to the right. This CL resets the x
position on restart.

Bug: 1001938
Change-Id: I1a2c83070c3dfc80811fec4d08876db1102734e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1840211Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Edward Jung (EMEA) <edwardjung@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703628}
parent d2ac07f4
......@@ -1618,6 +1618,7 @@ function Trex(canvas, spritePos) {
this.spritePos = spritePos;
this.xPos = 0;
this.yPos = 0;
this.xInitialPos = 0;
// Position when on the ground.
this.groundYPos = 0;
this.currentFrame = 0;
......@@ -1630,7 +1631,6 @@ function Trex(canvas, spritePos) {
this.config = Trex.config;
// Current status.
this.status = Trex.status.WAITING;
this.jumping = false;
this.ducking = false;
this.jumpVelocity = 0;
......@@ -1779,6 +1779,7 @@ Trex.prototype = {
if (this.playingIntro && this.xPos < this.config.START_X_POS) {
this.xPos += Math.round((this.config.START_X_POS /
this.config.INTRO_DURATION) * deltaTime);
this.xInitialPos = this.xPos;
}
if (this.status == Trex.status.WAITING) {
......@@ -1957,6 +1958,7 @@ Trex.prototype = {
* Reset the t-rex to running at start of game.
*/
reset: function() {
this.xPos = this.xInitialPos;
this.yPos = this.groundYPos;
this.jumpVelocity = 0;
this.jumping = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment