Progress: Client Side Prediction

This commit is contained in:
Jeremiah Billmann
2013-06-12 21:39:33 -04:00
parent e987d73711
commit 649fece9f0
3 changed files with 7 additions and 26 deletions
+6 -19
View File
@@ -5,6 +5,9 @@ options = {
onPlayerUpdate: function (data),
onPlayerDisconnect: function (id),
onPing: function (data),
logging: true,
clientSidePrediction: true,
onUpdatePhysics: function (state, inputs)
}
*/
@@ -111,6 +114,9 @@ window.GarageServerIO = (function (window, socketio) {
addPlayerInput = function (input) {
sequenceNumber += 1;
inputs.push(input);
if (options.clientSidePrediction && options.onUpdatePhysics) {
}
sendPlayerInput(input);
},
@@ -119,23 +125,6 @@ window.GarageServerIO = (function (window, socketio) {
socket.emit('input', { input: input, seq: sequenceNumber, timestamp: currentTime });
},
processPlayerInput = function () {
for (var i = 0; i < players.length; i ++) {
if (players[i].id !== socket.socket.sessionid) {
}
}
},
processClientInput = function () {
for (var i = 0; i < players.length; i ++) {
if (players[i].id === socket.socket.sessionid) {
break;
}
}
},
getPlayerStates = function (stateCallback) {
var maxUpdate = 0;
for (var i = 0; i < players.length; i ++) {
@@ -153,8 +142,6 @@ window.GarageServerIO = (function (window, socketio) {
return {
connectToGarageServer: connectToGarageServer,
addPlayerInput: addPlayerInput,
processPlayerInput: processPlayerInput,
processClientInput: processClientInput,
getPlayerStates: getPlayerStates
};
-6
View File
@@ -34,11 +34,6 @@ $(function () {
}
},
processServerInput = function () {
//GarageServerIO.processPlayerInput
//GarageServerIO.processClientInput
},
draw = function () {
ctxGameCanvas.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
@@ -51,7 +46,6 @@ $(function () {
requestAnimFrame(update);
processClientInput();
processServerInput();
draw();
+1 -1
View File
@@ -2,7 +2,7 @@ var garageServerGame = require('./garageservergame');
/*
options = {
onUpdatePhysics: function (state, input),
onUpdatePhysics: function (state, inputs),
physicsInterval: 15,
playersInterval: 45,
logging: true,