mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-01 16:50:06 +08:00
Progress: Client Updates
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -30,8 +30,6 @@ $(function () {
|
||||
y -= 1;
|
||||
GarageServerIO.addPlayerInput('up');
|
||||
}
|
||||
|
||||
GarageServerIO.sendPlayerInput();
|
||||
},
|
||||
|
||||
update = function () {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user