Removed set player state from client - should set from server

This commit is contained in:
Jeremiah Billmann
2013-07-14 12:02:24 -04:00
parent 4911079981
commit 5a778589ea
7 changed files with 3 additions and 46 deletions
+1 -6
View File
@@ -233,10 +233,6 @@ var GarageServerIO = (function (socketio) {
return _stateController.id;
},
setState = function (state) {
_socket.emit('playerState', state);
},
addInput = function (clientInput) {
_playerController.entities.some(function (player) {
if (player.id === _stateController.id) {
@@ -341,8 +337,7 @@ var GarageServerIO = (function (socketio) {
initializeGarageServer: initializeGarageServer,
addInput: addInput,
getStates: getStates,
getId: getId,
setState: setState
getId: getId
};
}) (io);
-1
View File
@@ -13,7 +13,6 @@ $(function () {
document.getElementById('gameCanvas').style.height = state.height + 'px';
}
});
GarageServerIO.setState({ x: 0, y: 0 });
GameLoop.start(
//Render Loop
+1 -1
View File
@@ -18,7 +18,7 @@
state.y -= (50 * deltaTime);
} else if (inputs[i].input === 'space') {
if (garageServer) {
//garageServer.addEntity(new guid());
garageServer.addEntity(new guid(), { x: state.x, y: state.y, direction: '' });
}
}
}
@@ -31,13 +31,5 @@ EntityController.prototype = {
return;
}
}
},
setState: function (id, state) {
this.entities.some(function (entity) {
if (entity.client.id === id) {
entity.state = state;
return true;
}
});
}
};
@@ -34,14 +34,4 @@ PlayerController.prototype.addInput = function (id, input, sequence, time) {
return true;
}
});
};
PlayerController.prototype.setState = function (id, state) {
this.entities.some(function (player) {
if (player.client.id === id) {
player.state = state;
player.inputs = [];
return true;
}
});
};
+1 -16
View File
@@ -13,8 +13,7 @@ options = {
onPlayerConnect: function (socket),
onPlayerInput: function (socket, input),
onPlayerDisconnect: function (socket),
onPing: function (socket, data),
onPlayerState: function (socket, data),
onPing: function (socket, data)
}
*/
@@ -62,13 +61,6 @@ GarageServer.prototype.registerSocketEvents = function (options) {
}
self.onPing(socket, data, options);
});
socket.on('playerState', function (data) {
if (options.logging) {
console.log('garageserver.io:: socket playerState ' + data);
}
self.onPlayerState(socket, data, options);
});
});
};
@@ -101,13 +93,6 @@ GarageServer.prototype.onPing = function (socket, data, options) {
}
};
GarageServer.prototype.onPlayerState = function (socket, data, options) {
this.game.setPlayerState(socket.id, data);
if (options.onPlayerState) {
options.onPlayerState(socket, data);
}
};
GarageServer.prototype.start = function () {
this.game.start();
};
-4
View File
@@ -100,10 +100,6 @@ GarageServerGame.prototype.removeEntity = function (id) {
this.entityController.remove(id);
};
GarageServerGame.prototype.setPlayerState = function (id, state) {
this.playerController.setState(id, state);
};
GarageServerGame.prototype.addPlayerInput = function (id, input, sequence, time) {
this.playerController.addInput(id, input, sequence, time);
};