diff --git a/client/garageserver.io.js b/client/garageserver.io.js index 85a7eed..d64c761 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -72,13 +72,13 @@ window.GarageServerIO = (function (window, socketio) { function Entity(id) { this.updates = []; this.id = id; - this.currentState = {}; + this.state = {}; } Entity.prototype = { addUpate: function (state, seq, time) { var newUpdate = new Update(state, seq, time); if (this.updates.length === 0) { - this.currentState = newUpdate.state; + this.state = newUpdate.state; } this.updates.push(newUpdate); if (this.updates.length > 120) { @@ -317,7 +317,7 @@ window.GarageServerIO = (function (window, socketio) { getEntityStatesCurrent = function (entityController) { entityController.entities.forEach(function (entity) { if (entity.anyUpdates()) { - entity.currentState = entity.latestUpdate().state; + entity.state = entity.latestUpdate().state; } }); }, @@ -330,7 +330,7 @@ window.GarageServerIO = (function (window, socketio) { if (positions.previous && positions.target) { amount = getInterpolatedAmount(positions.previous.time, positions.target.time); newState = _options.onInterpolation(entity.id, positions.previous.state, positions.target.state, amount); - entity.currentState = newState = _options.onInterpolation(entity.id, entity.currentState, newState, _stateController.smoothingFactor); + entity.state = newState = _options.onInterpolation(entity.id, entity.state, newState, _stateController.smoothingFactor); } } }); diff --git a/example/public/javascripts/game.js b/example/public/javascripts/game.js index f58bc42..cc9743d 100644 --- a/example/public/javascripts/game.js +++ b/example/public/javascripts/game.js @@ -20,11 +20,11 @@ $(function () { GarageServerIO.getStates(function (selfState, playerStates, entityStates) { playerStates.forEach(function (player) { - ctxCanvas.fillRect(player.currentState.x, player.currentState.y, 15, 15); + ctxCanvas.fillRect(player.state.x, player.state.y, 15, 15); }); entityStates.forEach(function (entity) { - ctxCanvas.fillRect(entity.currentState.x, entity.currentState.y, 15, 15); + ctxCanvas.fillRect(entity.state.x, entity.state.y, 15, 15); }); ctxCanvas.fillRect(selfState.x, selfState.y, 15, 15);