mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-19 11:19:49 +08:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
function GarageServerGame (options) {
|
|
this.players = [];
|
|
|
|
this.physicsIntervalId = setInterval(this.updatePhysics, options.physicsInterval ? options.physicsInterval : 15);
|
|
this.playersIntervalId = setInterval(this.updatePlayers, options.playersInterval ? options.playersInterval : 45);
|
|
}
|
|
|
|
GarageServerGame.prototype.updatePlayers = function () {
|
|
|
|
};
|
|
|
|
GarageServerGame.prototype.updatePhysics = function () {
|
|
|
|
};
|
|
|
|
GarageServerGame.prototype.addPlayer = function (client) {
|
|
for(var i = 0; i < this.players.length; i ++) {
|
|
if(this.players[i].id === client.id) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
var player = {
|
|
client: client,
|
|
inputs: []
|
|
};
|
|
|
|
this.players.push(player);
|
|
};
|
|
|
|
GarageServerGame.prototype.removePlayer = function (client) {
|
|
for(var i = 0; i < this.players.length; i ++) {
|
|
if(this.players[i].id === client.id) {
|
|
this.players.splice(i, 1)[0];
|
|
}
|
|
}
|
|
};
|
|
|
|
exports.createGame = function (options){
|
|
return new GarageServerGame(options);
|
|
}; |