From faf5434d2349e4f6f2f01c1395d32cbd85ab6582 Mon Sep 17 00:00:00 2001 From: Jeremiah Billmann Date: Tue, 9 Jul 2013 21:32:22 -0400 Subject: [PATCH] Removed unused physics code --- client/garageserver.io.js | 6 +++--- example/public/javascripts/game.js | 2 +- example/shared/core.js | 21 --------------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/client/garageserver.io.js b/client/garageserver.io.js index d64c761..0c701d3 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -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); } }, diff --git a/example/public/javascripts/game.js b/example/public/javascripts/game.js index cc9743d..907ad29 100644 --- a/example/public/javascripts/game.js +++ b/example/public/javascripts/game.js @@ -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)); diff --git a/example/shared/core.js b/example/shared/core.js index 9b247e1..f452da3 100644 --- a/example/shared/core.js +++ b/example/shared/core.js @@ -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;