diff options
| author | Brian Cully <bjc@spork.org> | 2025-12-22 19:27:54 -0500 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-12-22 19:27:54 -0500 |
| commit | acad2b35e50a250330975bda90f3e36002584f90 (patch) | |
| tree | cdaba65b67d24ad2426e8fcbab27f104c87fc114 /site/main.mjs | |
| parent | ef4807c680711a868d67b027a6fb618b920139ad (diff) | |
| download | automathon-acad2b35e50a250330975bda90f3e36002584f90.tar.gz automathon-acad2b35e50a250330975bda90f3e36002584f90.zip | |
js: only compute tween frames if time delta > 0
Diffstat (limited to 'site/main.mjs')
| -rw-r--r-- | site/main.mjs | 11 |
1 files changed, 7 insertions, 4 deletions
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); }); } |
