summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-02-10 21:58:00 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-02-10 22:01:38 -0500
commitc42111ad39d4b1ebef3d02d207e1f6bfa0d4022d (patch)
tree0ae5253173faa1ce4c5a1cca784fed8173c63c28
parent7cc965f26374c880ba129923438b1e4b39ac8f7e (diff)
game: Add on-start procedure.
* sly/game.scm (on-start): New procedure.
-rw-r--r--sly/game.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/sly/game.scm b/sly/game.scm
index 615f934..38d230e 100644
--- a/sly/game.scm
+++ b/sly/game.scm
@@ -40,6 +40,7 @@
draw-hook
after-game-loop-error-hook
game-started?
+ on-start
run-game-loop
stop-game-loop))
@@ -56,6 +57,16 @@
(define-signal game-started?
(hook->signal game-start-hook #f (lambda () #t)))
+(define-syntax on-start
+ (syntax-rules ()
+ "Create a signal that evaluates EXP once the game loop has started.
+If INIT is specified, the signal uses the result of this expression as
+its initial value, otherwise #f is the initial value."
+ ((_ exp)
+ (signal-if game-started? exp #f))
+ ((_ exp init)
+ (signal-if game-started? exp init))))
+
;;;
;;; Game Loop