From acad2b35e50a250330975bda90f3e36002584f90 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 22 Dec 2025 19:27:54 -0500 Subject: js: only compute tween frames if time delta > 0 --- site/main.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'site') diff --git a/site/main.mjs b/site/main.mjs index 46fea5f..f2012ab 100644 --- a/site/main.mjs +++ b/site/main.mjs @@ -117,10 +117,13 @@ function renderArena(robos, delta=0.0) { ctx.clearRect(0, 0, canvas.width, canvas.height); robos.forEach(robo => { - const [velx, vely] = [ - robo.speedx, robo.speedy - ].map(x => timeScale * x); - const [x, y] = clamp(25, robo.x + velx, robo.y + vely, canvas.width, canvas.height); + let [x, y] = [robo.x, robo.y]; + if (delta > 0) { + const [velx, vely] = [ + robo.speedx, robo.speedy + ].map(x => timeScale * x); + [x, y] = clamp(25, robo.x + velx, robo.y + vely, canvas.width, canvas.height); + } renderRobo(ctx, x, y); }); } -- cgit v1.3