@@ -35,7 +35,6 @@ var canvas = document.getElementById('canvas'),
35
35
launchVelocityOutput = document . getElementById ( 'launchVelocityOutput' ) ,
36
36
launchAngleOutput = document . getElementById ( 'launchAngleOutput' ) ,
37
37
38
- elapsedTime = undefined ,
39
38
launchTime = undefined ,
40
39
41
40
score = 0 ,
@@ -129,6 +128,7 @@ var canvas = document.getElementById('canvas'),
129
128
elapsedFlightTime ;
130
129
131
130
if ( ballInFlight ) {
131
+ if ( launchTime === undefined ) launchTime = time ;
132
132
elapsedFrameTime = ( time - this . lastTime ) / 1000 ,
133
133
elapsedFlightTime = ( time - launchTime ) / 1000 ;
134
134
@@ -158,7 +158,7 @@ var canvas = document.getElementById('canvas'),
158
158
else lastScore = 2 ;
159
159
160
160
score += lastScore ;
161
- scoreboard . innerText = score ;
161
+ scoreboard . innerHTML = score ;
162
162
} ,
163
163
164
164
execute : function ( bucket , context , time ) {
@@ -266,7 +266,7 @@ canvas.onmousedown = function(e) {
266
266
ball . velocityY = launchVelocity * Math . sin ( launchAngle ) ;
267
267
ballInFlight = true ;
268
268
threePointer = false ;
269
- launchTime = + new Date ( ) ;
269
+ launchTime = undefined ;
270
270
}
271
271
} ;
272
272
@@ -286,15 +286,14 @@ canvas.onmousemove = function (e) {
286
286
launchAngle = Math . atan ( parseFloat ( deltaY ) / parseFloat ( deltaX ) ) ;
287
287
launchVelocity = 4 * deltaY / Math . sin ( launchAngle ) / pixelsPerMeter ;
288
288
289
- launchVelocityOutput . innerText = launchVelocity . toFixed ( 2 ) ;
290
- launchAngleOutput . innerText = ( launchAngle * 180 / Math . PI ) . toFixed ( 2 ) ;
289
+ launchVelocityOutput . innerHTML = launchVelocity . toFixed ( 2 ) ;
290
+ launchAngleOutput . innerHTML = ( launchAngle * 180 / Math . PI ) . toFixed ( 2 ) ;
291
291
}
292
292
} ;
293
293
294
294
// Animation Loop................................................
295
295
296
296
function animate ( time ) {
297
- elapsedTime = ( time - launchTime ) / 1000 ;
298
297
context . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
299
298
300
299
if ( ! ballInFlight ) {
0 commit comments