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

Side by Side Diff: components/neterror/resources/offline.js

Issue 2132333003: Fix dinosaur offline game for iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 /** 82 /**
83 * Frames per second. 83 * Frames per second.
84 * @const 84 * @const
85 */ 85 */
86 var FPS = 60; 86 var FPS = 60;
87 87
88 /** @const */ 88 /** @const */
89 var IS_HIDPI = window.devicePixelRatio > 1; 89 var IS_HIDPI = window.devicePixelRatio > 1;
90 90
91 /** @const */ 91 /** @const */
92 var IS_IOS = window.navigator.userAgent.indexOf('CriOS') > -1 || 92 var IS_IOS = window.navigator.platform.substr(0,2) === 'iP';
93 window.navigator.userAgent == 'UIWebViewForStaticFileContent';
94 93
95 /** @const */ 94 /** @const */
96 var IS_MOBILE = window.navigator.userAgent.indexOf('Mobi') > -1 || IS_IOS; 95 var IS_MOBILE = window.navigator.userAgent.indexOf('Mobi') > -1 || IS_IOS;
97 96
98 /** @const */ 97 /** @const */
99 var IS_TOUCH_ENABLED = 'ontouchstart' in window; 98 var IS_TOUCH_ENABLED = 'ontouchstart' in window;
100 99
101 /** 100 /**
102 * Default game configuration. 101 * Default game configuration.
103 * @enum {number} 102 * @enum {number}
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 if (IS_MOBILE && this.activated) { 652 if (IS_MOBILE && this.activated) {
654 e.preventDefault(); 653 e.preventDefault();
655 } 654 }
656 655
657 if (e.target != this.detailsButton) { 656 if (e.target != this.detailsButton) {
658 if (!this.crashed && (Runner.keycodes.JUMP[e.keyCode] || 657 if (!this.crashed && (Runner.keycodes.JUMP[e.keyCode] ||
659 e.type == Runner.events.TOUCHSTART)) { 658 e.type == Runner.events.TOUCHSTART)) {
660 if (!this.activated) { 659 if (!this.activated) {
661 this.loadSounds(); 660 this.loadSounds();
662 this.activated = true; 661 this.activated = true;
663 errorPageController.trackEasterEgg(); 662 if (window.errorPageController) {
663 errorPageController.trackEasterEgg();
664 }
664 } 665 }
665 666
666 if (!this.tRex.jumping && !this.tRex.ducking) { 667 if (!this.tRex.jumping && !this.tRex.ducking) {
667 this.playSound(this.soundFx.BUTTON_PRESS); 668 this.playSound(this.soundFx.BUTTON_PRESS);
668 this.tRex.startJump(this.currentSpeed); 669 this.tRex.startJump(this.currentSpeed);
669 } 670 }
670 } 671 }
671 672
672 if (this.crashed && e.type == Runner.events.TOUCHSTART && 673 if (this.crashed && e.type == Runner.events.TOUCHSTART &&
673 e.currentTarget == this.containerEl) { 674 e.currentTarget == this.containerEl) {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 } 964 }
964 return bytes.buffer; 965 return bytes.buffer;
965 } 966 }
966 967
967 968
968 /** 969 /**
969 * Return the current timestamp. 970 * Return the current timestamp.
970 * @return {number} 971 * @return {number}
971 */ 972 */
972 function getTimeStamp() { 973 function getTimeStamp() {
973 return IS_IOS ? new Date().getTime() : performance.now(); 974 return performance.now();
974 } 975 }
975 976
976 977
977 //****************************************************************************** 978 //******************************************************************************
978 979
979 980
980 /** 981 /**
981 * Game over panel. 982 * Game over panel.
982 * @param {!HTMLCanvasElement} canvas 983 * @param {!HTMLCanvasElement} canvas
983 * @param {Object} textImgPos 984 * @param {Object} textImgPos
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 2681
2681 /** 2682 /**
2682 * Add a new cloud to the horizon. 2683 * Add a new cloud to the horizon.
2683 */ 2684 */
2684 addCloud: function() { 2685 addCloud: function() {
2685 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, 2686 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD,
2686 this.dimensions.WIDTH)); 2687 this.dimensions.WIDTH));
2687 } 2688 }
2688 }; 2689 };
2689 })(); 2690 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698