summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-02-17 20:52:51 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-02-17 20:52:51 -0500
commit4febe9a02f8f3c2f4e2104452e505d5a9ebc970f (patch)
tree31305f469b6b49ff3d9640a972956cacdd8493c6
parentdbcfc0b4b550a459bf00a4b4c783ba415c934c27 (diff)
Convert FPS counter to a signal.
* 2d/fps.scm (fps): Convert to signal. (accumulate-fps!): Set fps signal.
-rw-r--r--2d/fps.scm7
1 files changed, 3 insertions, 4 deletions
diff --git a/2d/fps.scm b/2d/fps.scm
index 58c7a86..4419928 100644
--- a/2d/fps.scm
+++ b/2d/fps.scm
@@ -23,22 +23,21 @@
(define-module (2d fps)
#:use-module (2d game)
+ #:use-module (2d signal)
#:export (fps))
;; Current frames per second
-(define fps (make-parameter 0))
+(define-signal fps (make-signal 0))
(define accumulate-fps!
(let* ((elapsed-time 0)
(fps-counter 0))
(lambda (dt alpha)
- "Increment the frames-per-second counter. Resets to 0 every
-second."
(let ((new-time (+ elapsed-time dt))
(new-fps (1+ fps-counter)))
(if (>= new-time 1000)
(begin
- (fps new-fps)
+ (signal-set! fps new-fps)
(set! fps-counter 0)
(set! elapsed-time 0))
(begin