reworking reconcilation and improved debug

This commit is contained in:
ari melody 2024-08-30 15:18:07 +01:00
parent cdaa7c678d
commit f1c9af7b6b
Signed by: ari
GPG key ID: CF99829C92678188
4 changed files with 251 additions and 142 deletions

View file

@ -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);
}