Progress: Adding delta time and fixed timestep

This commit is contained in:
Jeremiah Billmann
2013-07-01 21:03:05 -04:00
parent 7e66be0ac0
commit 9b7b0a9531
4 changed files with 14 additions and 12 deletions
+6 -5
View File
@@ -1,20 +1,21 @@
(function(exports){
exports.OnProcessGamePhysics = function (state, inputs) {
exports.OnProcessGamePhysics = function (state, inputs, deltaTime) {
var i = 0;
if (!state.x && !state.y) {
state.x = 0;
state.y = 0;
}
for (i = 0; i < inputs.length; i ++) {
if (inputs[i].input === 'left') {
state.x -= 1;
state.x -= (50 * deltaTime);
} else if (inputs[i].input === 'right') {
state.x += 1;
state.x += (50 * deltaTime);
} else if (inputs[i].input === 'down') {
state.y += 1;
state.y += (50 * deltaTime);
} else if (inputs[i].input === 'up') {
state.y -= 1;
state.y -= (50 * deltaTime);
}
}
return state;