From 87fd3c3e5fafb8af0f4218308b24abb1a4ba7603 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 27 Apr 2014 20:34:42 -0400 Subject: Ensure that interpolation alpha is clamped to the range [0, 1]. * 2d/game.scm (alpha): Clamp value to [0, 1]. --- 2d/game.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to '2d') 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." -- cgit v1.2.3