diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-24 12:15:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 13:30:04 +0000 |
commit | b014812705fc80bff0a5c120dfcef88f349816dc (patch) | |
tree | 25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/components/neterror | |
parent | 9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff) | |
download | qtwebengine-chromium-b014812705fc80bff0a5c120dfcef88f349816dc.tar.gz |
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/neterror')
-rw-r--r-- | chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite-bday.png | bin | 0 -> 1102 bytes | |||
-rw-r--r-- | chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite.png | bin | 2628 -> 2433 bytes | |||
-rw-r--r-- | chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite-bday.png | bin | 0 -> 1321 bytes | |||
-rw-r--r-- | chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite.png | bin | 3247 -> 3056 bytes | |||
-rw-r--r-- | chromium/components/neterror/resources/neterror.html | 3 | ||||
-rw-r--r-- | chromium/components/neterror/resources/offline.js | 165 |
6 files changed, 147 insertions, 21 deletions
diff --git a/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite-bday.png b/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite-bday.png Binary files differnew file mode 100644 index 00000000000..4654ee0b2d1 --- /dev/null +++ b/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite-bday.png diff --git a/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite.png b/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite.png Binary files differindex dcaf75941bf..24c3fcd1cca 100644 --- a/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite.png +++ b/chromium/components/neterror/resources/default_100_percent/offline/100-offline-sprite.png diff --git a/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite-bday.png b/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite-bday.png Binary files differnew file mode 100644 index 00000000000..38227e47c5b --- /dev/null +++ b/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite-bday.png diff --git a/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite.png b/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite.png Binary files differindex 366e82a910b..1a5ff75b9d6 100644 --- a/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite.png +++ b/chromium/components/neterror/resources/default_200_percent/offline/200-offline-sprite.png diff --git a/chromium/components/neterror/resources/neterror.html b/chromium/components/neterror/resources/neterror.html index 615d17162ed..464a56af290 100644 --- a/chromium/components/neterror/resources/neterror.html +++ b/chromium/components/neterror/resources/neterror.html @@ -2,6 +2,7 @@ <html dir="$i18n{textdirection}" lang="$i18n{language}"> <head> <meta charset="utf-8"> + <meta name="theme-color" content="#fff"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>$i18n{title}</title> @@ -77,6 +78,8 @@ <div id="offline-resources"> <img id="offline-resources-1x" src="default_100_percent/offline/100-offline-sprite.png"> <img id="offline-resources-2x" src="default_200_percent/offline/200-offline-sprite.png"> + <img id="offline-resources-bday-1x" src="default_100_percent/offline/100-offline-sprite-bday.png"> + <img id="offline-resources-bday-2x" src="default_200_percent/offline/200-offline-sprite-bday.png"> <template id="audio-resources"> <audio id="offline-sound-press" src="sounds/button-press.mp3"></audio> <audio id="offline-sound-hit" src="sounds/hit.mp3"></audio> diff --git a/chromium/components/neterror/resources/offline.js b/chromium/components/neterror/resources/offline.js index c4cf84dec29..53a21904563 100644 --- a/chromium/components/neterror/resources/offline.js +++ b/chromium/components/neterror/resources/offline.js @@ -49,6 +49,7 @@ function Runner(outerContainerId, opt_config) { this.inverted = false; this.invertTimer = 0; this.resizeTimerId_ = null; + this.bdayFlashTimer = null; this.playCount = 0; @@ -104,6 +105,9 @@ Runner.config = { ACCELERATION: 0.001, BG_CLOUD_SPEED: 0.2, BOTTOM_PAD: 10, + BOTTOM_PAD_BDAY: 26, + BDAY_FLASH_DURATION: 1000, + BDAY_Y_POS_ADJUST: 16, CLEAR_TIME: 3000, CLOUD_FREQUENCY: 0.5, GAMEOVER_CLEAR_TIME: 750, @@ -160,6 +164,7 @@ Runner.classes = { */ Runner.spriteDefinition = { LDPI: { + BALLOON: {x: 417, y: 29}, CACTUS_LARGE: {x: 332, y: 2}, CACTUS_SMALL: {x: 228, y: 2}, CLOUD: {x: 86, y: 2}, @@ -169,9 +174,12 @@ Runner.spriteDefinition = { RESTART: {x: 2, y: 2}, TEXT_SPRITE: {x: 655, y: 2}, TREX: {x: 848, y: 2}, + TREX_BDAY: {x: 0, y: 0}, + SNACK: {x: 384, y: 22}, STAR: {x: 645, y: 2} }, HDPI: { + BALLOON: {x: 834, y: 58}, CACTUS_LARGE: {x: 652, y: 2}, CACTUS_SMALL: {x: 446, y: 2}, CLOUD: {x: 166, y: 2}, @@ -181,6 +189,8 @@ Runner.spriteDefinition = { RESTART: {x: 2, y: 2}, TEXT_SPRITE: {x: 1294, y: 2}, TREX: {x: 1678, y: 2}, + TREX_BDAY: {x: 0, y: 0}, + SNACK: {x: 768, y: 44}, STAR: {x: 1276, y: 2} } }; @@ -287,9 +297,13 @@ Runner.prototype = { loadImages: function() { if (IS_HIDPI) { Runner.imageSprite = document.getElementById('offline-resources-2x'); + Runner.bdayImageSprite = + document.getElementById('offline-resources-bday-2x'); this.spriteDef = Runner.spriteDefinition.HDPI; } else { Runner.imageSprite = document.getElementById('offline-resources-1x'); + Runner.bdayImageSprite = + document.getElementById('offline-resources-bday-1x'); this.spriteDef = Runner.spriteDefinition.LDPI; } @@ -525,6 +539,20 @@ Runner.prototype = { var now = getTimeStamp(); var deltaTime = now - (this.time || now); + + // Flashing. + if (this.bdayFlashTimer != null) { + if (this.bdayFlashTimer <= 0) { + this.bdayFlashTimer = null; + this.tRex.setFlashing(false); + this.tRex.enableBdayMode(this.spriteDef.TREX_BDAY); + } else { + this.bdayFlashTimer -= deltaTime; + this.tRex.update(deltaTime); + deltaTime = 0; + } + } + this.time = now; if (this.playing) { @@ -555,6 +583,15 @@ Runner.prototype = { var collision = hasObstacles && checkForCollision(this.horizon.obstacles[0], this.tRex); + // Ate snack. + if (Runner.isBdayModeEnabled() && collision && + this.horizon.obstacles[0].typeConfig.type == 'SNACK') { + this.horizon.enableBdayMode(); + this.tRex.setFlashing(true); + collision = false; + this.bdayFlashTimer = this.config.BDAY_FLASH_DURATION; + } + if (!collision) { this.distanceRan += this.currentSpeed * deltaTime / this.msPerFrame; @@ -828,6 +865,7 @@ Runner.prototype = { this.tRex.reset(); this.playSound(this.soundFx.BUTTON_PRESS); this.invert(true); + this.bdayFlashTimer = null; this.update(); } }, @@ -957,6 +995,15 @@ Runner.updateCanvasScaling = function(canvas, opt_width, opt_height) { /** + * Whether the bday mode is enabled. + * @return {boolean} + */ +Runner.isBdayModeEnabled = function() { + return loadTimeData && loadTimeData.valueExists('bdayMode'); +} + + +/** * Get random number. * @param {number} min * @param {number} max @@ -1142,7 +1189,7 @@ function checkForCollision(obstacle, tRex, opt_canvasCtx) { tRex.xPos + 1, tRex.yPos + 1, tRex.config.WIDTH - 2, - tRex.config.HEIGHT - 2); + (tRex.bdayModeActive ? tRex.config.HEIGHT_BDAY : tRex.config.HEIGHT) - 2); var obstacleBox = new CollisionBox( obstacle.xPos + 1, @@ -1171,6 +1218,10 @@ function checkForCollision(obstacle, tRex, opt_canvasCtx) { createAdjustedCollisionBox(collisionBoxes[i], obstacleBox); var crashed = boxCompare(adjTrexBox, adjObstacleBox); + if (tRex.bdayModeActive) { + adjTrexBox.y += Runner.config.BDAY_Y_POS_ADJUST; + } + // Draw boxes for debug. if (opt_canvasCtx) { drawCollisionBoxes(opt_canvasCtx, adjTrexBox, adjObstacleBox); @@ -1287,6 +1338,8 @@ function Obstacle(canvasCtx, type, spriteImgPos, dimensions, this.collisionBoxes = []; this.gap = 0; this.speedOffset = 0; + this.imageSprite = this.typeConfig.type == 'SNACK' ? Runner.bdayImageSprite : + Runner.imageSprite; // For animated obstacles. this.currentFrame = 0; @@ -1378,7 +1431,7 @@ Obstacle.prototype = { sourceX += sourceWidth * this.currentFrame; } - this.canvasCtx.drawImage(Runner.imageSprite, + this.canvasCtx.drawImage(this.imageSprite, sourceX, this.spritePos.y, sourceWidth * this.size, sourceHeight, this.xPos, this.yPos, @@ -1508,6 +1561,18 @@ Obstacle.types = [ numFrames: 2, frameRate: 1000/6, speedOffset: .8 + }, + { + type: 'SNACK', + width: 33, + height: 42, + yPos: 85, + multipleSpeed: 999, + minGap: 999, + minSpeed: 0, + collisionBoxes: [ + new CollisionBox(0, 0, 40, 40) + ] } ]; @@ -1522,6 +1587,7 @@ Obstacle.types = [ function Trex(canvas, spritePos) { this.canvas = canvas; this.canvasCtx = canvas.getContext('2d'); + this.imageSprite = Runner.imageSprite; this.spritePos = spritePos; this.xPos = 0; this.yPos = 0; @@ -1545,6 +1611,8 @@ function Trex(canvas, spritePos) { this.speedDrop = false; this.jumpCount = 0; this.jumpspotX = 0; + this.bdayModeActive = false; + this.flashing = false; this.init(); }; @@ -1556,8 +1624,11 @@ function Trex(canvas, spritePos) { */ Trex.config = { DROP_VELOCITY: -5, + FLASH_OFF: 175, + FLASH_ON: 100, GRAVITY: 0.6, HEIGHT: 47, + HEIGHT_BDAY: 63, HEIGHT_DUCK: 25, INIITAL_JUMP_VELOCITY: -10, INTRO_DURATION: 1500, @@ -1631,7 +1702,7 @@ Trex.animFrames = { msPerFrame: 1000 / 60 }, DUCKING: { - frames: [262, 321], + frames: [264, 323], msPerFrame: 1000 / 8 } }; @@ -1653,6 +1724,25 @@ Trex.prototype = { }, /** + * @param {Object} spritePos New positioning within image sprite. + */ + enableBdayMode: function(spritePos) { + this.bdayModeActive = true; + this.spritePos = spritePos; + this.imageSprite = Runner.bdayImageSprite; + this.groundYPos = Runner.defaultDimensions.HEIGHT - this.config.HEIGHT - + Runner.config.BOTTOM_PAD_BDAY; + this.yPos -= Runner.config.BDAY_Y_POS_ADJUST; + }, + + /** + * @param {boolean} status Whether dino is flashing. + */ + setFlashing: function(status) { + this.flashing = status; + }, + + /** * Setter for the jump velocity. * The approriate drop velocity is also set. */ @@ -1695,7 +1785,7 @@ Trex.prototype = { } // Update the frame position. - if (this.timer >= this.msPerFrame) { + if (!this.flashing && this.timer >= this.msPerFrame) { this.currentFrame = this.currentFrame == this.currentAnimFrames.length - 1 ? 0 : this.currentFrame + 1; this.timer = 0; @@ -1718,7 +1808,10 @@ Trex.prototype = { var sourceY = y; var sourceWidth = this.ducking && this.status != Trex.status.CRASHED ? this.config.WIDTH_DUCK : this.config.WIDTH; - var sourceHeight = this.config.HEIGHT; + var sourceHeight = this.bdayModeActive ? this.config.HEIGHT_BDAY : + this.config.HEIGHT; + var outputHeight = sourceHeight; + if (IS_HIDPI) { sourceX *= 2; @@ -1731,23 +1824,33 @@ Trex.prototype = { sourceX += this.spritePos.x; sourceY += this.spritePos.y; + // Flashing. + if (this.flashing) { + if (this.timer < this.config.FLASH_ON) { + this.canvasCtx.globalAlpha = 0.5; + } else if (this.timer > this.config.FLASH_OFF) { + this.timer = 0; + } + } + // Ducking. if (this.ducking && this.status != Trex.status.CRASHED) { - this.canvasCtx.drawImage(Runner.imageSprite, sourceX, sourceY, + this.canvasCtx.drawImage(this.imageSprite, sourceX, sourceY, sourceWidth, sourceHeight, this.xPos, this.yPos, - this.config.WIDTH_DUCK, this.config.HEIGHT); + this.config.WIDTH_DUCK, outputHeight); } else { // Crashed whilst ducking. Trex is standing up so needs adjustment. if (this.ducking && this.status == Trex.status.CRASHED) { this.xPos++; } // Standing / running - this.canvasCtx.drawImage(Runner.imageSprite, sourceX, sourceY, + this.canvasCtx.drawImage(this.imageSprite, sourceX, sourceY, sourceWidth, sourceHeight, this.xPos, this.yPos, - this.config.WIDTH, this.config.HEIGHT); + this.config.WIDTH, outputHeight); } + this.canvasCtx.globalAlpha = 1; }, /** @@ -1835,8 +1938,6 @@ Trex.prototype = { this.reset(); this.jumpCount++; } - - this.update(deltaTime); }, /** @@ -2144,9 +2245,10 @@ DistanceMeter.prototype = { * Similar to an obstacle object but without collision boxes. * @param {HTMLCanvasElement} canvas Canvas element. * @param {Object} spritePos Position of image in sprite. + * @param {boolean} isBalloon Switch Cloud to balloon. * @param {number} containerWidth */ -function Cloud(canvas, spritePos, containerWidth) { +function Cloud(canvas, spritePos, containerWidth, isBalloon) { this.canvas = canvas; this.canvasCtx = this.canvas.getContext('2d'); this.spritePos = spritePos; @@ -2156,6 +2258,8 @@ function Cloud(canvas, spritePos, containerWidth) { this.remove = false; this.cloudGap = getRandomNum(Cloud.config.MIN_CLOUD_GAP, Cloud.config.MAX_CLOUD_GAP); + this.isBalloon = isBalloon; + this.imageSprite = isBalloon ? Runner.bdayImageSprite : Runner.imageSprite; this.init(); }; @@ -2167,11 +2271,13 @@ function Cloud(canvas, spritePos, containerWidth) { */ Cloud.config = { HEIGHT: 14, + HEIGHT_BALLOON: 34, MAX_CLOUD_GAP: 400, MAX_SKY_LEVEL: 30, MIN_CLOUD_GAP: 100, MIN_SKY_LEVEL: 71, - WIDTH: 46 + WIDTH: 46, + WIDTH_BALLOON: 16 }; @@ -2190,19 +2296,22 @@ Cloud.prototype = { */ draw: function() { this.canvasCtx.save(); - var sourceWidth = Cloud.config.WIDTH; - var sourceHeight = Cloud.config.HEIGHT; - + var sourceWidth = this.isBalloon ? Cloud.config.WIDTH_BALLOON : + Cloud.config.WIDTH; + var sourceHeight = this.isBalloon ? Cloud.config.HEIGHT_BALLOON : + Cloud.config.HEIGHT; + var outputWidth = sourceWidth; + var outputHeight = sourceHeight; if (IS_HIDPI) { sourceWidth = sourceWidth * 2; sourceHeight = sourceHeight * 2; } - this.canvasCtx.drawImage(Runner.imageSprite, this.spritePos.x, + this.canvasCtx.drawImage(this.imageSprite, this.spritePos.x, this.spritePos.y, sourceWidth, sourceHeight, this.xPos, this.yPos, - Cloud.config.WIDTH, Cloud.config.HEIGHT); + outputWidth, outputHeight); this.canvasCtx.restore(); }, @@ -2540,6 +2649,7 @@ function Horizon(canvas, spritePos, dimensions, gapCoefficient) { this.cloudFrequency = this.config.CLOUD_FREQUENCY; this.spritePos = spritePos; this.nightMode = null; + this.bdayModeActive = false; // Cloud this.clouds = []; @@ -2576,6 +2686,14 @@ Horizon.prototype = { }, /** + * Enable additional items. + */ + enableBdayMode: function() { + this.bdayModeActive = true; + this.removeFirstObstacle(); + }, + + /** * @param {number} deltaTime * @param {number} currentSpeed * @param {boolean} updateObstacles Used as an override to prevent @@ -2671,7 +2789,10 @@ Horizon.prototype = { * @param {number} currentSpeed */ addNewObstacle: function(currentSpeed) { - var obstacleTypeIndex = getRandomNum(0, Obstacle.types.length - 1); + var obstacleCount = Runner.isBdayModeEnabled() && + !this.bdayModeActive ? Obstacle.types.length - 1 : + Obstacle.types.length - 2; + var obstacleTypeIndex = getRandomNum(0, obstacleCount); var obstacleType = Obstacle.types[obstacleTypeIndex]; // Check for multiples of the same type of obstacle. @@ -2733,8 +2854,10 @@ Horizon.prototype = { * Add a new cloud to the horizon. */ addCloud: function() { - this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, - this.dimensions.WIDTH)); + var cloudType = this.bdayModeActive && getRandomNum(0, 1) > 0 ? + this.spritePos.BALLOON : this.spritePos.CLOUD; + this.clouds.push(new Cloud(this.canvas, cloudType, + this.dimensions.WIDTH, cloudType == this.spritePos.BALLOON)); } }; })(); |