mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-06-30 16:40:46 +08:00
Progress: #3
This commit is contained in:
@@ -13,25 +13,35 @@ function GarageServerGame(options) {
|
||||
}
|
||||
|
||||
GarageServerGame.prototype.updateState = function (options) {
|
||||
var currentTime = new Date().getTime() - this.startTime;
|
||||
this.updatePlayers(currentTime, options);
|
||||
this.updateEntities(currentTime, options);
|
||||
};
|
||||
var currentTime = new Date().getTime() - this.startTime,
|
||||
state = { time: currentTime, playerStates: [], entityStates: [] };
|
||||
|
||||
GarageServerGame.prototype.updatePlayers = function (currentTime, options) {
|
||||
var state = { time: currentTime, playerStates: [], entityStates: [] };
|
||||
|
||||
this.players.forEach(function (player) {
|
||||
state.playerStates.push([ player.client.id, player.state, player.sequence ]);
|
||||
});
|
||||
state.playerStates = this.updatePlayers();
|
||||
state.entityStates = this.updateEntities();
|
||||
|
||||
this.players.forEach(function (player) {
|
||||
player.client.emit('update', state);
|
||||
});
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updateEntities = function (currentTime, options) {
|
||||
|
||||
GarageServerGame.prototype.updatePlayers = function () {
|
||||
var states = [];
|
||||
|
||||
this.players.forEach(function (player) {
|
||||
states.push([ player.client.id, player.state, player.sequence ]);
|
||||
});
|
||||
|
||||
return states;
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updateEntities = function () {
|
||||
var states = [];
|
||||
|
||||
this.entities.forEach(function (entity) {
|
||||
states.push([ entity.id, entity.state, entity.sequence ]);
|
||||
});
|
||||
|
||||
return states;
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updatePhysics = function (options) {
|
||||
|
||||
Reference in New Issue
Block a user