summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2024-07-06 21:24:04 -0500
committersanine <sanine.not@pm.me>2024-07-06 21:24:04 -0500
commitc012fec2870757990080e823d42dd91031e64f25 (patch)
treefa5863939b883c0cf301cda333777cd543f350a1 /level.js
parent03528a25215330d3b00cabdb1bbe7ce701e1bfeb (diff)
set rocket to relatively constant velocity
Diffstat (limited to 'level.js')
-rw-r--r--level.js7
1 files changed, 5 insertions, 2 deletions
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);
}