From c42111ad39d4b1ebef3d02d207e1f6bfa0d4022d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 10 Feb 2016 21:58:00 -0500 Subject: game: Add on-start procedure. * sly/game.scm (on-start): New procedure. --- sly/game.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- cgit v1.2.3