summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-04-27 20:34:42 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-04-27 20:34:42 -0400
commit87fd3c3e5fafb8af0f4218308b24abb1a4ba7603 (patch)
tree6460d03809badf70d37b2b797ba0b378a3a099b7
parentff4799b1c8800d35d4a06230b0782ca6af7708d0 (diff)
Ensure that interpolation alpha is clamped to the range [0, 1].
* 2d/game.scm (alpha): Clamp value to [0, 1].
-rw-r--r--2d/game.scm3
1 files changed, 2 insertions, 1 deletions
diff --git a/2d/game.scm b/2d/game.scm
index ac33881..09c3c11 100644
--- a/2d/game.scm
+++ b/2d/game.scm
@@ -27,6 +27,7 @@
#:use-module (gl)
#:use-module (2d agenda)
#:use-module (2d event)
+ #:use-module (2d math)
#:use-module (2d signal)
#:use-module (2d window)
#:export (tick-interval
@@ -76,7 +77,7 @@ is the unused accumulator time."
(define (alpha lag)
"Calculate interpolation factor in the range [0, 1] for the
leftover frame time LAG."
- (/ lag tick-interval))
+ (clamp 0 1 (/ lag tick-interval)))
(define (frame-sleep time)
"Sleep for the remainder of the frame that started at TIME."