diff options
-rw-r--r-- | sly/game.scm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sly/game.scm b/sly/game.scm index 6e82b78..615f934 100644 --- a/sly/game.scm +++ b/sly/game.scm @@ -36,18 +36,31 @@ #:use-module (sly math vector) #:use-module (sly window) #:use-module (sly render) - #:export (draw-hook + #:export (game-start-hook + draw-hook after-game-loop-error-hook + game-started? + run-game-loop stop-game-loop)) + ;;; -;;; Game Loop +;;; Hooks and initializers ;;; +(define game-start-hook (make-hook)) (define draw-hook (make-hook 2)) (define after-game-loop-error-hook (make-hook)) +(define-signal game-started? + (hook->signal game-start-hook #f (lambda () #t))) + + +;;; +;;; Game Loop +;;; + (define (interval rate) (floor (/ 1000 rate))) @@ -159,6 +172,7 @@ milliseconds of the last iteration of the game loop." (lambda (signum) (stop-game-loop))) ;; Let's play! + (run-hook game-start-hook) (game-loop (sdl-ticks) 0)) (lambda (cont callback) (when (procedure? callback) |