Merge remote-tracking branch 'upstream/master' into best-score
Conflicts: index.html js/application.js js/html_actuator.js
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
(function() {
|
||||
var lastTime = 0;
|
||||
var vendors = ['webkit', 'moz'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame =
|
||||
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
}
|
||||
|
||||
if (!window.cancelAnimationFrame) {
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
}
|
||||
}());
|
||||
+3
-5
@@ -1,6 +1,4 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Wait till the browser is ready to render the game (avoids glitches)
|
||||
window.requestAnimationFrame(function () {
|
||||
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
|
||||
});
|
||||
// Wait till the browser is ready to render the game (avoids glitches)
|
||||
window.requestAnimationFrame(function () {
|
||||
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
|
||||
});
|
||||
|
||||
@@ -31,11 +31,15 @@ KeyboardInputManager.prototype.listen = function () {
|
||||
75: 0, // vim keybindings
|
||||
76: 1,
|
||||
74: 2,
|
||||
72: 3
|
||||
72: 3,
|
||||
87: 0, // W
|
||||
68: 1, // D
|
||||
83: 2, // S
|
||||
65: 3 // A
|
||||
};
|
||||
|
||||
document.addEventListener("keydown", function (event) {
|
||||
var modifiers = event.altKey && event.ctrlKey && event.metaKey &&
|
||||
var modifiers = event.altKey || event.ctrlKey || event.metaKey ||
|
||||
event.shiftKey;
|
||||
var mapped = map[event.which];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user