Code cleanup

This commit is contained in:
Jeremiah Billmann
2013-06-08 15:29:57 -05:00
parent 815bf73cde
commit 675807e1b3
5 changed files with 205 additions and 211 deletions
+5 -5
View File
@@ -21,7 +21,7 @@ function GarageServer (socketio, options) {
GarageServer.prototype.registerSocketEvents = function (options) {
var self = this;
self.io.of('/garageserver.io').on('connection', function (socket) {
if (options.logging) {
console.log('garageserver.io:: socket ' + socket.id + ' connection');
@@ -68,18 +68,18 @@ GarageServer.prototype.onPlayerDisconnect = function (socket, options) {
GarageServer.prototype.onPlayerInput = function (socket, input, options) {
this.game.addPlayerInput(socket, input);
if(options.onPlayerInput) {
if (options.onPlayerInput) {
options.onPlayerInput(socket, input);
}
};
GarageServer.prototype.onPing = function(socket, data, options) {
GarageServer.prototype.onPing = function (socket, data, options) {
socket.emit('ping', data);
if (options.onPing) {
options.onPing(socket, data);
}
};
exports.createGarageServer = function (io, options){
return new GarageServer(io, options);
exports.createGarageServer = function (io, options) {
return new GarageServer(io, options);
};
+3 -3
View File
@@ -1,4 +1,4 @@
function GarageServerGame (options) {
function GarageServerGame(options) {
var self = this;
this.players = [];
@@ -8,7 +8,7 @@ function GarageServerGame (options) {
this.playersIntervalId = setInterval(function () { self.updatePlayers(options); }, options.playersInterval ? options.playersInterval : 45);
}
GarageServerGame.prototype.updatePlayers = function () {
GarageServerGame.prototype.updatePlayers = function (options) {
var currentTime = new Date().getTime();
for (var i = 0; i < this.players.length; i ++) {
//TODO: Retink efficiency
@@ -17,7 +17,7 @@ GarageServerGame.prototype.updatePlayers = function () {
}
};
GarageServerGame.prototype.updatePhysics = function () {
GarageServerGame.prototype.updatePhysics = function (options) {
for (var i = 0; i < this.players.length; i ++) {
if (this.players[i].inputs.length > 0) {
if (this.options.onUpdatePhysics) {