Progress: Interpolation Correction

This commit is contained in:
Jeremiah Billmann
2013-06-30 16:05:26 -04:00
parent bbe9adf06b
commit a052a414c3
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -21,9 +21,11 @@ window.GarageServerIO = (function (window, socketio) {
function StateController() {
this.state = {};
this.time;
this.delta;
this.physicsDelta;
this.stateDelta;
this.playerId;
this.pingDelay = 100;
this.renderTime = 0;
this.fps = 0;
this.fpsLastUpdate = (new Date()) * 1 - 1;
this.fpsFilter = 50;
@@ -31,6 +33,7 @@ window.GarageServerIO = (function (window, socketio) {
StateController.prototype = {
setTime: function (serverTime, delay) {
this.time = serverTime - delay;
this.renderTime = this.time;
}
};
@@ -226,8 +229,9 @@ window.GarageServerIO = (function (window, socketio) {
},
updateState = function (data) {
_stateController.stateDelta = data.stateDelta;
_stateController.physicsDelta = data.physicsDelta;
_stateController.setTime(data.time, _options.interpolationDelay ? _options.interpolationDelay : 100);
_stateController.delta = data.delta;
updatePlayersState(data);
updateEntitiesState(data);
+1 -1
View File
@@ -19,7 +19,7 @@ GarageServerGame.prototype.updateState = function (options) {
GarageServerGame.prototype.updatePlayers = function (options) {
var currentTime = new Date().getTime() - this.startTime,
state = { time: currentTime, delta: this.physicsInterval, playerStates: [] };
state = { time: currentTime, physicsDelta: this.physicsInterval, stateDelta: this.stateInterval, playerStates: [] };
this.players.forEach(function (player) {
state.playerStates.push({ id: player.client.id, state: player.state, seq: player.sequence });