diff options
| author | Brian Cully <bjc@spork.org> | 2025-12-22 13:07:34 -0500 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-12-22 13:07:34 -0500 |
| commit | 874834b026300fab646ccefdaceb33bc4ff499b7 (patch) | |
| tree | 3001dac9d1e95451723186f916d80bfd6a41bcb1 | |
| parent | d1f0ff8dc6eeab71b4beda3006e5fd318eb33b6e (diff) | |
| download | automathon-874834b026300fab646ccefdaceb33bc4ff499b7.tar.gz automathon-874834b026300fab646ccefdaceb33bc4ff499b7.zip | |
js: fix movement jump on tick
| -rw-r--r-- | site/main.mjs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/site/main.mjs b/site/main.mjs index 877c0bc..958e82d 100644 --- a/site/main.mjs +++ b/site/main.mjs @@ -200,6 +200,13 @@ async function loaded() { renderTextHighlight(trans); robo.lastTick = document.timeline.currentTime; + + const canvas = document.querySelector(CANVAS_SELECTOR); + const [x, y] = clamp(25, robo.x + robo.speedx, robo.y + robo.speedy, canvas.width, canvas.height); + robo.x = x; + robo.y = y; + renderArena([robo]); + robo.heading = trans.vars.heading; robo.speed = trans.vars.speed; const [speedx, speedy] = [ @@ -208,11 +215,6 @@ async function loaded() { ].map(x => robo.speed * x); robo.speedx = speedx; robo.speedy = speedy; - const canvas = document.querySelector(CANVAS_SELECTOR); - const [x, y] = clamp(25, robo.x + speedx, robo.y + speedy, canvas.width, canvas.height); - robo.x = x; - robo.y = y; - renderArena([robo]); break; default: console.error('invalid message from robo worker', e.data); |
