Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/renderer/resources/offline.js

Issue 609853002: Offline intersitital - Fix sprite clipping and clipped button highlight (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add OWNERS file to chrome/renderer/resources Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/resources/neterror.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 (function() { 4 (function() {
5 'use strict'; 5 'use strict';
6 /** 6 /**
7 * T-Rex runner. 7 * T-Rex runner.
8 * @param {string} outerContainerId Outer containing element id. 8 * @param {string} outerContainerId Outer containing element id.
9 * @param {object} opt_config 9 * @param {object} opt_config
10 * @constructor 10 * @constructor
11 * @export 11 * @export
12 */ 12 */
13 function Runner(outerContainerId, opt_config) { 13 function Runner(outerContainerId, opt_config) {
14 // Singleton 14 // Singleton
15 if (Runner.instance_) { 15 if (Runner.instance_) {
16 return Runner.instance_; 16 return Runner.instance_;
17 } 17 }
18 Runner.instance_ = this; 18 Runner.instance_ = this;
19 19
20 this.outerContainerEl = document.querySelector(outerContainerId); 20 this.outerContainerEl = document.querySelector(outerContainerId);
21 this.containerEl = null; 21 this.containerEl = null;
22 this.detailsButton = this.outerContainerEl.querySelector('#details-button');
22 23
23 this.config = opt_config || Runner.config; 24 this.config = opt_config || Runner.config;
24 25
25 this.dimensions = Runner.defaultDimensions; 26 this.dimensions = Runner.defaultDimensions;
26 27
27 this.canvas = null; 28 this.canvas = null;
28 this.canvasCtx = null; 29 this.canvasCtx = null;
29 30
30 this.tRex = null; 31 this.tRex = null;
31 32
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 document.removeEventListener(Runner.events.MOUSEDOWN, this); 572 document.removeEventListener(Runner.events.MOUSEDOWN, this);
572 document.removeEventListener(Runner.events.MOUSEUP, this); 573 document.removeEventListener(Runner.events.MOUSEUP, this);
573 } 574 }
574 }, 575 },
575 576
576 /** 577 /**
577 * Process keydown. 578 * Process keydown.
578 * @param {Event} e 579 * @param {Event} e
579 */ 580 */
580 onKeyDown: function(e) { 581 onKeyDown: function(e) {
581 if (!this.crashed && (Runner.keycodes.JUMP[String(e.keyCode)] || 582 if (e.target != this.detailsButton) {
582 e.type == Runner.events.TOUCHSTART)) { 583 if (!this.crashed && (Runner.keycodes.JUMP[String(e.keyCode)] ||
583 if (!this.activated) { 584 e.type == Runner.events.TOUCHSTART)) {
584 this.loadSounds(); 585 if (!this.activated) {
585 this.activated = true; 586 this.loadSounds();
587 this.activated = true;
588 }
589
590 if (!this.tRex.jumping) {
591 this.playSound(this.soundFx.BUTTON_PRESS);
592 this.tRex.startJump();
593 }
586 } 594 }
587 595
588 if (!this.tRex.jumping) { 596 if (this.crashed && e.type == Runner.events.TOUCHSTART &&
589 this.playSound(this.soundFx.BUTTON_PRESS); 597 e.currentTarget == this.containerEl) {
590 this.tRex.startJump(); 598 this.restart();
591 } 599 }
592 } 600 }
593 601
594 if (this.crashed && e.type == Runner.events.TOUCHSTART &&
595 e.currentTarget == this.containerEl) {
596 this.restart();
597 }
598
599 // Speed drop, activated only when jump key is not pressed. 602 // Speed drop, activated only when jump key is not pressed.
600 if (Runner.keycodes.DUCK[e.keyCode] && this.tRex.jumping) { 603 if (Runner.keycodes.DUCK[e.keyCode] && this.tRex.jumping) {
601 e.preventDefault(); 604 e.preventDefault();
602 this.tRex.setSpeedDrop(); 605 this.tRex.setSpeedDrop();
603 } 606 }
604 }, 607 },
605 608
606 609
607 /** 610 /**
608 * Process key up. 611 * Process key up.
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 1851
1849 this.init(); 1852 this.init();
1850 }; 1853 };
1851 1854
1852 1855
1853 /** 1856 /**
1854 * Cloud object config. 1857 * Cloud object config.
1855 * @enum {number} 1858 * @enum {number}
1856 */ 1859 */
1857 Cloud.config = { 1860 Cloud.config = {
1858 HEIGHT: 13, 1861 HEIGHT: 14,
1859 MAX_CLOUD_GAP: 400, 1862 MAX_CLOUD_GAP: 400,
1860 MAX_SKY_LEVEL: 30, 1863 MAX_SKY_LEVEL: 30,
1861 MIN_CLOUD_GAP: 100, 1864 MIN_CLOUD_GAP: 100,
1862 MIN_SKY_LEVEL: 71, 1865 MIN_SKY_LEVEL: 71,
1863 WIDTH: 46 1866 WIDTH: 46
1864 }; 1867 };
1865 1868
1866 1869
1867 Cloud.prototype = { 1870 Cloud.prototype = {
1868 /** 1871 /**
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2229
2227 /** 2230 /**
2228 * Add a new cloud to the horizon. 2231 * Add a new cloud to the horizon.
2229 */ 2232 */
2230 addCloud: function() { 2233 addCloud: function() {
2231 this.clouds.push(new Cloud(this.canvas, this.cloudImg, 2234 this.clouds.push(new Cloud(this.canvas, this.cloudImg,
2232 this.dimensions.WIDTH)); 2235 this.dimensions.WIDTH));
2233 } 2236 }
2234 }; 2237 };
2235 })(); 2238 })();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/neterror.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698