Hack around animation wackiness when user switches windows for awhile.
This commit is contained in:
parent
faf4fa7124
commit
770a5e6b7d
1 changed files with 13 additions and 5 deletions
10
game.scm
10
game.scm
|
@ -570,11 +570,19 @@
|
|||
(let* ((time (/ time 1000.0))
|
||||
(dt (- time *frame-time*)))
|
||||
(set! *frame-time* time)
|
||||
;; 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)
|
||||
(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*)
|
||||
|
|
Loading…
Add table
Reference in a new issue