mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-03 17:10:20 +08:00
Removed unused physics code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user