diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-02-17 20:52:51 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-02-17 20:52:51 -0500 |
commit | 4febe9a02f8f3c2f4e2104452e505d5a9ebc970f (patch) | |
tree | 31305f469b6b49ff3d9640a972956cacdd8493c6 | |
parent | dbcfc0b4b550a459bf00a4b4c783ba415c934c27 (diff) |
Convert FPS counter to a signal.
* 2d/fps.scm (fps): Convert to signal.
(accumulate-fps!): Set fps signal.
-rw-r--r-- | 2d/fps.scm | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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 |