Progress: Client Updates

This commit is contained in:
Jeremiah Billmann
2013-06-01 14:57:04 -04:00
parent a9f92adf60
commit d676f72e19
3 changed files with 6 additions and 10 deletions
+3 -5
View File
@@ -8,8 +8,6 @@ window.GarageServerIO = (function (window, socketio) {
players = [],
inputs = [],
updates = [],
// TODO: DONE CALLBACK
@@ -36,11 +34,11 @@ window.GarageServerIO = (function (window, socketio) {
addPlayerInput = function (input) {
sequenceNumber += 1;
inputs.push({ input: input, seq: sequenceNumber });
sendPlayerInput(input);
},
sendPlayerInput = function () {
sendPlayerInput = function (input) {
socket.emit('input', { input: input, seq: sequenceNumber });
},
removePlayer = function (id) {
-2
View File
@@ -30,8 +30,6 @@ $(function () {
y -= 1;
GarageServerIO.addPlayerInput('up');
}
GarageServerIO.sendPlayerInput();
},
update = function () {
+3 -3
View File
@@ -29,7 +29,7 @@ GarageServerGame.prototype.updatePhysics = function (options) {
GarageServerGame.prototype.addPlayer = function (client) {
for(var i = 0; i < this.players.length; i ++) {
if(this.players[i].id === client.id) {
if(this.players[i].client.id === client.id) {
return;
}
}
@@ -46,7 +46,7 @@ GarageServerGame.prototype.addPlayer = function (client) {
GarageServerGame.prototype.removePlayer = function (client) {
for(var i = 0; i < this.players.length; i ++) {
if(this.players[i].id === client.id) {
if(this.players[i].client.id === client.id) {
this.players.splice(i, 1)[0];
return;
}
@@ -55,7 +55,7 @@ GarageServerGame.prototype.removePlayer = function (client) {
GarageServerGame.prototype.addPlayerInput = function (client, input) {
for(var i = 0; i < this.players.length; i ++) {
if(this.players[i].id === client.id) {
if(this.players[i].client.id === client.id) {
this.players[i].inputs.push(input);
return;
}