Shared physics code - meant to show sharing, not best practices

This commit is contained in:
Jeremiah Billmann
2013-06-28 16:25:42 -04:00
parent 94601cd295
commit bf8ddc5a7f
5 changed files with 29 additions and 39 deletions
+23
View File
@@ -0,0 +1,23 @@
(function(exports){
exports.OnProcessGamePhysics = function (state, inputs) {
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;
} else if (inputs[i].input === 'right') {
state.x += 1;
} else if (inputs[i].input === 'down') {
state.y += 1;
} else if (inputs[i].input === 'up') {
state.y -= 1;
}
}
return state;
};
})(typeof exports === 'undefined' ? window : exports);
View File