Removed unused physics code

This commit is contained in:
Jeremiah Billmann
2013-07-09 21:32:22 -04:00
parent cd0a076424
commit faf5434d23
3 changed files with 4 additions and 25 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ options = {
onPlayerRemove: function (id),
onGameState: function (state),
onPing: function (pingDelay),
onUpdatePlayerPhysics: function (id, state, inputs, deltaTime),
onUpdatePlayerPhysics: function (state, inputs, deltaTime),
onInterpolation: function(id, previousState, targetState, amount)
logging: true
}
@@ -238,7 +238,7 @@ window.GarageServerIO = (function (window, socketio) {
addPlayerInput = function (clientInput) {
_inputController.add(clientInput);
if (_stateController.clientSidePrediction && _options.onUpdatePlayerPhysics) {
_stateController.state = _options.onUpdatePlayerPhysics(_stateController.playerId, _stateController.state, [{ input: clientInput }], _stateController.physicsDelta);
_stateController.state = _options.onUpdatePlayerPhysics(_stateController.state, [{ input: clientInput }], _stateController.physicsDelta);
}
_socket.emit('input', [ clientInput, _inputController.sequenceNumber, _stateController.renderTime ]);
},
@@ -269,7 +269,7 @@ window.GarageServerIO = (function (window, socketio) {
_inputController.remove(playerState[2]);
if (_stateController.clientSidePrediction && _inputController.any()) {
_stateController.state = _options.onUpdatePlayerPhysics(_stateController.playerId, _stateController.state, _inputController.inputs, _stateController.physicsDelta);
_stateController.state = _options.onUpdatePlayerPhysics(_stateController.state, _inputController.inputs, _stateController.physicsDelta);
}
},
+1 -1
View File
@@ -3,7 +3,7 @@ $(function () {
GarageServerIO.initializeGarageServer('http://garageserver_io.jbillmann.c9.io', {
logging: true,
onUpdatePlayerPhysics: onUpdatePlayerPhysics,
onUpdatePlayerPhysics: getNewPlayerState,
onInterpolation: function (id, previousState, targetState, amount) {
var interpolationState = {};
interpolationState.x = (previousState.x + amount * (targetState.x - previousState.x));
-21
View File
@@ -1,26 +1,5 @@
(function(exports){
exports.onUpdatePlayerPhysics = function (id, 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 -= (50 * deltaTime);
} else if (inputs[i].input === 'right') {
state.x += (50 * deltaTime);
} else if (inputs[i].input === 'down') {
state.y += (50 * deltaTime);
} else if (inputs[i].input === 'up') {
state.y -= (50 * deltaTime);
}
}
return state;
};
exports.getNewPlayerState = function (state, inputs, deltaTime) {
var i = 0;