summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
Diffstat (limited to '2d')
-rw-r--r--2d/game.scm19
1 files changed, 6 insertions, 13 deletions
diff --git a/2d/game.scm b/2d/game.scm
index 7c618aa..3e1f982 100644
--- a/2d/game.scm
+++ b/2d/game.scm
@@ -34,8 +34,8 @@
#:use-module (2d repl repl)
#:use-module (2d signals)
#:use-module (2d vector2)
- #:export (game-draw
- run-game
+ #:export (draw-hook
+ run-game-loop
quit-game
pause-game
resume-game
@@ -48,25 +48,19 @@
;;; Game Loop
;;;
-(define (default-draw)
- #f)
-
;; Possible states are:
;; * stopped
;; * running
;; * paused
(define %state 'stopped)
-(define %draw #f)
-(define game-draw (make-root-signal 0))
;; TODO: Make this configurable
(define ticks-per-second 60)
(define tick-interval (floor (/ 1000 ticks-per-second)))
+(define draw-hook (make-hook))
-(define* (run-game #:optional #:key
- (draw default-draw))
+(define (run-game-loop)
"Start the game loop."
(set! %state 'running)
- (set! %draw draw)
(resume-game)
(spawn-server)
(game-loop (SDL:get-ticks) 0))
@@ -76,8 +70,7 @@
(set-gl-matrix-mode (matrix-mode modelview))
(gl-load-identity)
(gl-clear (clear-buffer-mask color-buffer depth-buffer))
- (signal-set! game-draw alpha)
- (%draw)
+ (run-hook draw-hook)
(SDL:gl-swap-buffers)
(accumulate-fps! dt))
@@ -88,7 +81,7 @@ is the unused accumulator time."
(if (>= accumulator tick-interval)
(begin
(handle-events)
- (update-agenda)
+ (tick-agenda!)
(update (- accumulator tick-interval)))
accumulator))