diff --git a/game.scm b/game.scm index eb5f005..fe28a30 100644 --- a/game.scm +++ b/game.scm @@ -570,11 +570,19 @@ (let* ((time (/ time 1000.0)) (dt (- time *frame-time*))) (set! *frame-time* time) - (update-animation anim:player dt) - (update-animation anim:electron-head dt) - (update-animation anim:electron-tail dt) - (update-animation anim:gem dt) - (update-animation anim:ghost-gem dt) + ;; Prevent SUPER SPEED animations when the user switches away from + ;; the browser for awhile. To my surprise, + ;; blur/focus/visibilitychanged events *DO NOT* trigger when the + ;; user switches to another program window, at least on my + ;; machine, so they are useless to prevent this problem. Instead, + ;; we hack: Don't update animations if dt is unreasonably high, + ;; for some definition of unreasonable. + (unless (> dt 0.2) + (update-animation anim:player dt) + (update-animation anim:electron-head dt) + (update-animation anim:electron-tail dt) + (update-animation anim:gem dt) + (update-animation anim:ghost-gem dt)) (clear-rect context 0.0 0.0 *canvas-width* *canvas-height*) (set-transform! context 1.0 0.0 0.0 1.0 0.0 0.0) (scale! context *canvas-scale* *canvas-scale*)