reworking reconcilation and improved debug
This commit is contained in:
parent
cdaa7c678d
commit
f1c9af7b6b
4 changed files with 251 additions and 142 deletions
|
@ -77,6 +77,8 @@ export function init(http_server) {
|
|||
name: client.player.name,
|
||||
x: client.player.x,
|
||||
y: client.player.y,
|
||||
xv: client.player.xv,
|
||||
yv: client.player.yv,
|
||||
col: client.player.colour,
|
||||
};
|
||||
});
|
||||
|
@ -168,17 +170,18 @@ export function init(http_server) {
|
|||
|
||||
function update() {
|
||||
var delta = (performance.now() - last_update) / 1000;
|
||||
last_update = performance.now();
|
||||
|
||||
// update players
|
||||
var frame_players = {};
|
||||
clients.forEach(client => {
|
||||
if (!client.player) return;
|
||||
client.player.update(delta);
|
||||
client.player.x = Math.max(Math.min(client.player.x, WORLD_SIZE), 0);
|
||||
client.player.y = Math.max(Math.min(client.player.y, WORLD_SIZE), 0);
|
||||
frame_players[client.id] = {
|
||||
x: client.player.x,
|
||||
y: client.player.y,
|
||||
xv: client.player.xv,
|
||||
yv: client.player.yv,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -211,7 +214,6 @@ function update() {
|
|||
}));
|
||||
})
|
||||
|
||||
last_update = performance.now();
|
||||
ticks++;
|
||||
setTimeout(update, 1000 / TICK_RATE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue