From 43e8242619451dc70b0e30d71aec0f0bea7547ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6hring?= Date: Tue, 14 Feb 2023 00:48:46 +0100 Subject: [PATCH] fix falling-on-pause bug The issue happened because of not resetting lastTick: The lastTick is stored to calculate movement speed independent of frame rate. When paused, the delta is calculated with the time before the pause, so it gets huge and results in high velocity values that are used to calculate how far the player moved. --- src/App.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index cc83e4a..20544ef 100644 --- a/src/App.vue +++ b/src/App.vue @@ -75,7 +75,10 @@ const move = (thisTick: number): void => { animationFrame = requestAnimationFrame(move) // do nothing when paused - if (paused.value) return + if (paused.value) { + lastTick = thisTick // reset tick, to avoid huge tickDelta + return + } const tickDelta = thisTick - lastTick lastTimeUpdate += tickDelta