summaryrefslogtreecommitdiff
path: root/level.js
diff options
context:
space:
mode:
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);
}