refactor: timestamp precision

This commit is contained in:
cha0s 2024-08-12 21:48:06 -05:00
parent e15e94777f
commit 77dcb7c5a1

View File

@ -29,7 +29,7 @@ export default class Engine {
frame = 0;
handle;
incomingActions = new Map();
last = Date.now();
last;
server;
constructor(Server) {
@ -398,10 +398,12 @@ export default class Engine {
}
start() {
this.last = performance.now() / 1000;
const loop = async () => {
const now = performance.now() / 1000;
const elapsed = now - this.last;
this.last = now;
this.acceptActions();
const elapsed = (Date.now() - this.last) / 1000;
this.last = Date.now();
this.tick(elapsed);
this.update(elapsed);
this.setClean();