mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-28 11:15:16 +08:00
Progress: input processing
This commit is contained in:
+9
-4
@@ -47,19 +47,24 @@ garageServer.createGarageServer(sockets, {
|
||||
logging: true,
|
||||
onUpdatePhysics: 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] === 'left') {
|
||||
if (inputs[i].input === 'left') {
|
||||
state.x -= 1;
|
||||
}
|
||||
else if (inputs[i] === 'right') {
|
||||
else if (inputs[i].input === 'right') {
|
||||
state.x += 1;
|
||||
}
|
||||
else if (inputs[i] === 'down') {
|
||||
else if (inputs[i].input === 'down') {
|
||||
state.y += 1;
|
||||
}
|
||||
else if (inputs[i] === 'up') {
|
||||
else if (inputs[i].input === 'up') {
|
||||
state.y -= 1;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user