]> git.jsancho.org Git - gacela.git/commitdiff
Frames per second.
authorjsancho <devnull@localhost>
Sun, 25 Dec 2011 20:57:50 +0000 (20:57 +0000)
committerjsancho <devnull@localhost>
Sun, 25 Dec 2011 20:57:50 +0000 (20:57 +0000)
src/gacela.scm
src/video.scm

index d6515ec2f45ae3e38a377fae2f59502738962e6c..256e940c78c64f9df172551a3698b14428288fd6 100644 (file)
 ;        (refresh-active-mobs)
   (set! loop-flag #t)
   (init-video 640 480 32)
-;        (quit! #f)
   (while loop-flag
-;          (init-frame-time)
+        (init-frame-time)
 ;          (check-connections)
         (process-events)
         (cond ((not (quit?))
                           (lambda (key . args) #f)))
 ;                        (run-mobs)
                (flip-screen)
-;                 (delay-frame))))
-               )))
+               (delay-frame))))
   (quit-video))
 
 (define (game-running?)
index e0b7a6da10823354c930a724a25bae533771dcf9..7eda879b8b6834d6f810057352e833bbbbbc8a47 100644 (file)
 
 ;;; Frames per second
 
-(define set-frames-per-second #f)
-(define init-frame-time #f)
-(define get-frame-time #f)
-(define delay-frame #f)
-
-;; (let ((time 0) (time-per-frame (/ 1000.0 *frames-per-second*)))
-;;   (set! set-frames-per-second
-;;     (lambda (fps)
-;;       (set! time-per-frame (/ 1000.0 fps))))
-
-;;   (set! init-frame-time
-;;     (lambda ()
-;;       (set! time (SDL_GetTicks))))
-
-;;   (set! get-frame-time
-;;     (lambda ()
-;;       time))
-
-;;   (set! delay-frame
-;;     (lambda ()
-;;       (let ((frame-time (- (SDL_GetTicks) time)))
-;;         (cond ((< frame-time time-per-frame)
-;;                (SDL_Delay (- time-per-frame frame-time))))))))
+(define time 0)
+(define time-per-frame 50)   ;in ms
+
+(define (set-frames-per-second fps)
+  (set! time-per-frame (/ 1000.0 fps)))
+
+(define (init-frame-time)
+  (set! time (SDL_GetTicks)))
+
+(define (get-frame-time)
+  time)
+
+(define (delay-frame)
+  (let ((frame-time (- (SDL_GetTicks) time)))
+    (cond ((< frame-time time-per-frame)
+          (SDL_Delay (- time-per-frame frame-time))))))
 
 
 ;;; Drawing