From c012fec2870757990080e823d42dd91031e64f25 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 6 Jul 2024 21:24:04 -0500 Subject: set rocket to relatively constant velocity --- level.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'level.js') diff --git a/level.js b/level.js index 637694f..9f6ee60 100644 --- a/level.js +++ b/level.js @@ -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); } -- cgit v1.2.1