Update HTML5-Space-Invaders.html
This commit is contained in:
parent
9c7514abd2
commit
8b8a44a88d
|
@ -1323,26 +1323,27 @@
|
||||||
|
|
||||||
// animation loop
|
// animation loop
|
||||||
var gameWrapper = $("#game");
|
var gameWrapper = $("#game");
|
||||||
var startTime = window.performance.now() || window.mozAnimationStartTime || +new Date;
|
//var startTime = window.performance.now() || window.mozAnimationStartTime || +new Date;
|
||||||
|
//startTime = (window.performance && window.performance.now) ? performance.now() : (window.mozAnimationStartTime ? window.mozAnimationStartTime : +new Date());
|
||||||
|
|
||||||
requestAnimationFrame(loop, gameWrapper);
|
//requestAnimationFrame(loop, gameWrapper);
|
||||||
function loop(timestamp) {
|
(function loop(timestamp) {
|
||||||
// time since last draw
|
// time since last draw
|
||||||
var drawStart = (timestamp || +new Date);
|
//var drawStart = (timestamp || +new Date);
|
||||||
var diff = drawStart - startTime;
|
//var diff = drawStart - startTime;
|
||||||
|
|
||||||
// update frame rate
|
// update frame rate
|
||||||
if (diff > 1000/66)
|
//if (diff > 1000/33)
|
||||||
{
|
//{
|
||||||
// animation
|
// animation
|
||||||
gameLoop();
|
gameLoop();
|
||||||
|
|
||||||
// reset startTime
|
// reset startTime
|
||||||
startTime = drawStart;
|
//startTime = drawStart;
|
||||||
}
|
//}
|
||||||
|
|
||||||
requestAnimationFrame(loop, gameWrapper);
|
requestAnimationFrame(loop, gameWrapper);
|
||||||
}
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
img.src = spriteSheet;
|
img.src = spriteSheet;
|
||||||
|
@ -1463,18 +1464,19 @@
|
||||||
|
|
||||||
// animation loop
|
// animation loop
|
||||||
var gameWrapper = $("#game");
|
var gameWrapper = $("#game");
|
||||||
debugger;
|
//var startTime = window.performance.now() || window.mozAnimationStartTime || +new Date;
|
||||||
var startTime = window.performance.now() || window.mozAnimationStartTime || +new Date;
|
//startTime = (window.performance && window.performance.now) ? performance.now() : (window.mozAnimationStartTime ? window.mozAnimationStartTime : +new Date());
|
||||||
requestAnimationFrame(loop, gameWrapper);
|
|
||||||
function loop(timestamp) {
|
//requestAnimationFrame(loop, gameWrapper);
|
||||||
|
(function loop(timestamp) {
|
||||||
|
|
||||||
// time since last draw
|
// time since last draw
|
||||||
var drawStart = (timestamp || +new Date);
|
//var drawStart = (timestamp || +new Date);
|
||||||
var diff = drawStart - startTime;
|
//var diff = drawStart - startTime;
|
||||||
|
|
||||||
// update frame rate
|
// update frame rate
|
||||||
if (diff > 1000/60)
|
//if (diff > 1000/30)
|
||||||
{
|
//{
|
||||||
// animation
|
// animation
|
||||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
sky.drawStars();
|
sky.drawStars();
|
||||||
|
@ -1482,11 +1484,11 @@
|
||||||
if (human.credit > 0) textHelper.changeTextColor("#play");
|
if (human.credit > 0) textHelper.changeTextColor("#play");
|
||||||
|
|
||||||
// reset startTime
|
// reset startTime
|
||||||
startTime = drawStart;
|
//startTime = drawStart;
|
||||||
}
|
//}
|
||||||
|
|
||||||
requestAnimationFrame(loop, gameWrapper);
|
requestAnimationFrame(loop, gameWrapper);
|
||||||
}
|
}());
|
||||||
};
|
};
|
||||||
|
|
||||||
var _instructions = function() {
|
var _instructions = function() {
|
||||||
|
|
Loading…
Reference in New Issue