mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-27 11:18:04 +08:00
Progress: Client Side Prediction
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ var garageServerGame = require('./garageservergame');
|
||||
|
||||
/*
|
||||
options = {
|
||||
onUpdatePhysics: function (state, input),
|
||||
onUpdatePhysics: function (state, inputs),
|
||||
physicsInterval: 15,
|
||||
playersInterval: 45,
|
||||
logging: true,
|
||||
|
||||
Reference in New Issue
Block a user