diff options
author | sanine <sanine.not@pm.me> | 2024-07-06 21:24:04 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2024-07-06 21:24:04 -0500 |
commit | c012fec2870757990080e823d42dd91031e64f25 (patch) | |
tree | fa5863939b883c0cf301cda333777cd543f350a1 /level.js | |
parent | 03528a25215330d3b00cabdb1bbe7ce701e1bfeb (diff) |
set rocket to relatively constant velocity
Diffstat (limited to 'level.js')
-rw-r--r-- | level.js | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -174,9 +174,12 @@ function stepLevel(ui, level, index) { finishLevel(ui, level, false); render(ui.ctx, level, 0); } else if (level.running && index < level.path.length-1) { - setTimeout(() => stepLevel(ui, level, index+1), 1); + const distNext = distance(pos, level.path[index+1] || pos); + setTimeout(() => stepLevel(ui, level, index+1), 50*distNext); } else { - finishLevel(ui, level, true); + if (index >= level.path.length-1) { + finishLevel(ui, level, true); + } level.running = false; render(ui.ctx, level, 0); } |