33 var vendors = [ 'ms' , 'moz' , 'webkit' , 'o' ] ;
44 for ( var x = 0 ; x < vendors . length && ! window . requestAnimationFrame ; ++ x ) {
55 window . requestAnimationFrame = window [ vendors [ x ] + 'RequestAnimationFrame' ] ;
6- window . cancelAnimationFrame =
6+ window . cancelAnimationFrame =
77 window [ vendors [ x ] + 'CancelAnimationFrame' ] || window [ vendors [ x ] + 'CancelRequestAnimationFrame' ] ;
88 }
9-
9+
1010 if ( ! window . requestAnimationFrame )
1111 window . requestAnimationFrame = function ( callback , element ) {
1212 var currTime = new Date ( ) . getTime ( ) ;
1313 var timeToCall = Math . max ( 0 , 16 - ( currTime - lastTime ) ) ;
14- var id = window . setTimeout ( function ( ) { callback ( currTime + timeToCall ) ; } ,
14+ var id = window . setTimeout ( function ( ) { callback ( currTime + timeToCall ) ; } ,
1515 timeToCall ) ;
1616 lastTime = currTime + timeToCall ;
1717 return id ;
1818 } ;
19-
19+
2020 if ( ! window . cancelAnimationFrame )
2121 window . cancelAnimationFrame = function ( id ) {
2222 clearTimeout ( id ) ;
2323 } ;
2424} ( ) ) ;
25-
2625
27- var Game = new function ( ) {
26+
27+ var Game = new function ( ) {
2828 var boards = [ ] ;
2929
3030 // Game Initialization
@@ -43,15 +43,15 @@ var Game = new function() {
4343
4444 this . setupInput ( ) ;
4545
46- this . loop ( ) ;
46+ this . loop ( ) ;
4747
4848 if ( this . mobile ) {
4949 this . setBoard ( 4 , new TouchControls ( ) ) ;
5050 }
5151
5252 SpriteSheet . load ( sprite_data , callback ) ;
5353 } ;
54-
54+
5555
5656 // Handle Input
5757 var KEY_CODES = { 37 :'left' , 39 :'right' , 32 :'fire' } ;
@@ -67,7 +67,7 @@ var Game = new function() {
6767
6868 window . addEventListener ( 'keyup' , function ( e ) {
6969 if ( KEY_CODES [ e . keyCode ] ) {
70- Game . keys [ KEY_CODES [ e . keyCode ] ] = false ;
70+ Game . keys [ KEY_CODES [ e . keyCode ] ] = false ;
7171 e . preventDefault ( ) ;
7272 }
7373 } , false ) ;
@@ -77,21 +77,21 @@ var Game = new function() {
7777 var lastTime = new Date ( ) . getTime ( ) ;
7878 var maxTime = 1 / 30 ;
7979 // Game Loop
80- this . loop = function ( ) {
80+ this . loop = function ( ) {
8181 var curTime = new Date ( ) . getTime ( ) ;
8282 requestAnimationFrame ( Game . loop ) ;
8383 var dt = ( curTime - lastTime ) / 1000 ;
8484 if ( dt > maxTime ) { dt = maxTime ; }
8585
8686 for ( var i = 0 , len = boards . length ; i < len ; i ++ ) {
87- if ( boards [ i ] ) {
87+ if ( boards [ i ] ) {
8888 boards [ i ] . step ( dt ) ;
8989 boards [ i ] . draw ( Game . ctx ) ;
9090 }
9191 }
9292 lastTime = curTime ;
9393 } ;
94-
94+
9595 // Change an active game board
9696 this . setBoard = function ( num , board ) { boards [ num ] = board ; } ;
9797
@@ -100,7 +100,7 @@ var Game = new function() {
100100 var container = document . getElementById ( "container" ) ,
101101 hasTouch = ! ! ( 'ontouchstart' in window ) ,
102102 w = window . innerWidth , h = window . innerHeight ;
103-
103+
104104 if ( hasTouch ) { this . mobile = true ; }
105105
106106 if ( screen . width >= 1280 || ! hasTouch ) { return false ; }
@@ -139,9 +139,9 @@ var Game = new function() {
139139
140140
141141var SpriteSheet = new function ( ) {
142- this . map = { } ;
142+ this . map = { } ;
143143
144- this . load = function ( spriteData , callback ) {
144+ this . load = function ( spriteData , callback ) {
145145 this . map = spriteData ;
146146 this . image = new Image ( ) ;
147147 this . image . onload = callback ;
@@ -152,9 +152,9 @@ var SpriteSheet = new function() {
152152 var s = this . map [ sprite ] ;
153153 if ( ! frame ) frame = 0 ;
154154 ctx . drawImage ( this . image ,
155- s . sx + frame * s . w ,
156- s . sy ,
157- s . w , s . h ,
155+ s . sx + frame * s . w ,
156+ s . sy ,
157+ s . w , s . h ,
158158 Math . floor ( x ) , Math . floor ( y ) ,
159159 s . w , s . h ) ;
160160 } ;
@@ -173,7 +173,7 @@ var TitleScreen = function TitleScreen(title,subtitle,callback) {
173173 ctx . fillStyle = "#FFFFFF" ;
174174
175175 ctx . font = "bold 40px bangers" ;
176- var measure = ctx . measureText ( title ) ;
176+ var measure = ctx . measureText ( title ) ;
177177 ctx . fillText ( title , Game . width / 2 - measure . width / 2 , Game . height / 2 ) ;
178178
179179 ctx . font = "bold 20px bangers" ;
@@ -191,18 +191,18 @@ var GameBoard = function() {
191191 this . cnt = { } ;
192192
193193 // Add a new object to the object list
194- this . add = function ( obj ) {
195- obj . board = this ;
196- this . objects . push ( obj ) ;
194+ this . add = function ( obj ) {
195+ obj . board = this ;
196+ this . objects . push ( obj ) ;
197197 this . cnt [ obj . type ] = ( this . cnt [ obj . type ] || 0 ) + 1 ;
198- return obj ;
198+ return obj ;
199199 } ;
200200
201201 // Mark an object for removal
202- this . remove = function ( obj ) {
202+ this . remove = function ( obj ) {
203203 var idx = this . removed . indexOf ( obj ) ;
204204 if ( idx == - 1 ) {
205- this . removed . push ( obj ) ;
205+ this . removed . push ( obj ) ;
206206 return true ;
207207 } else {
208208 return false ;
@@ -223,7 +223,7 @@ var GameBoard = function() {
223223 }
224224 } ;
225225
226- // Call the same method on all current objects
226+ // Call the same method on all current objects
227227 this . iterate = function ( funcName ) {
228228 var args = Array . prototype . slice . call ( arguments , 1 ) ;
229229 for ( var i = 0 , len = this . objects . length ; i < len ; i ++ ) {
@@ -242,7 +242,7 @@ var GameBoard = function() {
242242
243243 // Call step on all objects and them delete
244244 // any object that have been marked for removal
245- this . step = function ( dt ) {
245+ this . step = function ( dt ) {
246246 this . resetRemoved ( ) ;
247247 this . iterate ( 'step' , dt ) ;
248248 this . finalizeRemoved ( ) ;
@@ -253,7 +253,7 @@ var GameBoard = function() {
253253 this . iterate ( 'draw' , ctx ) ;
254254 } ;
255255
256- // Check for a collision between the
256+ // Check for a collision between the
257257 // bounding rects of two objects
258258 this . overlap = function ( o1 , o2 ) {
259259 return ! ( ( o1 . y + o1 . h - 1 < o2 . y ) || ( o1 . y > o2 . y + o2 . h - 1 ) ||
@@ -318,9 +318,9 @@ Level.prototype.step = function(dt) {
318318
319319 // Start, End, Gap, Type, Override
320320 // [ 0, 4000, 500, 'step', { x: 100 } ]
321- while ( ( curShip = this . levelData [ idx ] ) &&
321+ while ( ( curShip = this . levelData [ idx ] ) &&
322322 ( curShip [ 0 ] < this . t + 2000 ) ) {
323- // Check if we've passed the end time
323+ // Check if we've passed the end time
324324 if ( this . t > curShip [ 1 ] ) {
325325 remove . push ( curShip ) ;
326326 } else if ( curShip [ 0 ] < this . t ) {
@@ -343,7 +343,7 @@ Level.prototype.step = function(dt) {
343343 if ( remIdx != - 1 ) this . levelData . splice ( remIdx , 1 ) ;
344344 }
345345
346- // If there are no more enemies on the board or in
346+ // If there are no more enemies on the board or in
347347 // levelData, this level is done
348348 if ( this . levelData . length === 0 && this . board . cnt [ OBJECT_ENEMY ] === 0 ) {
349349 if ( this . callback ) this . callback ( ) ;
@@ -371,8 +371,8 @@ var TouchControls = function() {
371371
372372 var txtSize = ctx . measureText ( txt ) ;
373373
374- ctx . fillText ( txt ,
375- x + blockWidth / 2 - txtSize . width / 2 ,
374+ ctx . fillText ( txt ,
375+ x + blockWidth / 2 - txtSize . width / 2 ,
376376 y + 3 * blockWidth / 4 + 5 ) ;
377377 } ;
378378
@@ -400,10 +400,10 @@ var TouchControls = function() {
400400 x = touch . pageX / Game . canvasMultiplier - Game . canvas . offsetLeft ;
401401 if ( x < unitWidth ) {
402402 Game . keys [ 'left' ] = true ;
403- }
403+ }
404404 if ( x > unitWidth && x < 2 * unitWidth ) {
405405 Game . keys [ 'right' ] = true ;
406- }
406+ }
407407 }
408408
409409 if ( e . type == 'touchstart' || e . type == 'touchend' ) {
0 commit comments