Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 */ | 285 */ |
| 286 loadImages: function() { | 286 loadImages: function() { |
| 287 if (IS_HIDPI) { | 287 if (IS_HIDPI) { |
| 288 Runner.imageSprite = document.getElementById('offline-resources-2x'); | 288 Runner.imageSprite = document.getElementById('offline-resources-2x'); |
| 289 this.spriteDef = Runner.spriteDefinition.HDPI; | 289 this.spriteDef = Runner.spriteDefinition.HDPI; |
| 290 } else { | 290 } else { |
| 291 Runner.imageSprite = document.getElementById('offline-resources-1x'); | 291 Runner.imageSprite = document.getElementById('offline-resources-1x'); |
| 292 this.spriteDef = Runner.spriteDefinition.LDPI; | 292 this.spriteDef = Runner.spriteDefinition.LDPI; |
| 293 } | 293 } |
| 294 | 294 |
| 295 this.init(); | 295 if(!Runner.imageSprite.complete) { |
|
Eugene But (OOO till 7-30)
2016/07/13 05:28:57
Space after |if|
kkhorimoto
2016/07/13 17:54:53
Done.
| |
| 296 // If the images are not yet loaded, add a listener. | |
| 297 Runner.imageSprite.runner = this; | |
| 298 | |
| 299 Runner.imageSprite.onload = function() { | |
| 300 this.runner.init(); | |
| 301 } | |
| 302 } else { | |
| 303 this.init(); | |
| 304 } | |
| 296 }, | 305 }, |
| 297 | 306 |
| 298 /** | 307 /** |
| 299 * Load and decode base 64 encoded sounds. | 308 * Load and decode base 64 encoded sounds. |
| 300 */ | 309 */ |
| 301 loadSounds: function() { | 310 loadSounds: function() { |
| 302 if (!IS_IOS) { | 311 if (!IS_IOS) { |
| 303 this.audioContext = new AudioContext(); | 312 this.audioContext = new AudioContext(); |
| 304 | 313 |
| 305 var resourceTemplate = | 314 var resourceTemplate = |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 if (IS_MOBILE && this.activated) { | 662 if (IS_MOBILE && this.activated) { |
| 654 e.preventDefault(); | 663 e.preventDefault(); |
| 655 } | 664 } |
| 656 | 665 |
| 657 if (e.target != this.detailsButton) { | 666 if (e.target != this.detailsButton) { |
| 658 if (!this.crashed && (Runner.keycodes.JUMP[e.keyCode] || | 667 if (!this.crashed && (Runner.keycodes.JUMP[e.keyCode] || |
| 659 e.type == Runner.events.TOUCHSTART)) { | 668 e.type == Runner.events.TOUCHSTART)) { |
| 660 if (!this.activated) { | 669 if (!this.activated) { |
| 661 this.loadSounds(); | 670 this.loadSounds(); |
| 662 this.activated = true; | 671 this.activated = true; |
| 663 errorPageController.trackEasterEgg(); | 672 if (window.errorPageController) { |
|
Eugene But (OOO till 7-30)
2016/07/13 05:28:57
Optional NIT: Maybe s/window.errorPageController/e
kkhorimoto
2016/07/13 17:54:53
Done.
| |
| 673 errorPageController.trackEasterEgg(); | |
| 674 } | |
| 664 } | 675 } |
| 665 | 676 |
| 666 if (!this.tRex.jumping && !this.tRex.ducking) { | 677 if (!this.tRex.jumping && !this.tRex.ducking) { |
| 667 this.playSound(this.soundFx.BUTTON_PRESS); | 678 this.playSound(this.soundFx.BUTTON_PRESS); |
| 668 this.tRex.startJump(this.currentSpeed); | 679 this.tRex.startJump(this.currentSpeed); |
| 669 } | 680 } |
| 670 } | 681 } |
| 671 | 682 |
| 672 if (this.crashed && e.type == Runner.events.TOUCHSTART && | 683 if (this.crashed && e.type == Runner.events.TOUCHSTART && |
| 673 e.currentTarget == this.containerEl) { | 684 e.currentTarget == this.containerEl) { |
| (...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2680 | 2691 |
| 2681 /** | 2692 /** |
| 2682 * Add a new cloud to the horizon. | 2693 * Add a new cloud to the horizon. |
| 2683 */ | 2694 */ |
| 2684 addCloud: function() { | 2695 addCloud: function() { |
| 2685 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, | 2696 this.clouds.push(new Cloud(this.canvas, this.spritePos.CLOUD, |
| 2686 this.dimensions.WIDTH)); | 2697 this.dimensions.WIDTH)); |
| 2687 } | 2698 } |
| 2688 }; | 2699 }; |
| 2689 })(); | 2700 })(); |
| OLD | NEW |