From d0ff41fb7a33c096a792ab57f5bbf7992b1cc399 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 4 May 2014 14:03:00 -0400 Subject: Add current-agenda parameter. * 2d/agenda.scm (current-agenda): New variable. (with-agenda): New macro. (agenda-time, tick-agenda!, clear-agenda!, schedule) (schedule-interval, schedule-each, wait): Remove agenda parameter. * 2d/game.scm (game-agenda): Delete it. (update): Tick current agenda. * 2d/helpers.scm (define-guardian): Remove agenda argument. * 2d/repl.scm (start-2d-repl): Remove agenda argument to schedule-each. * 2d/signal.scm (signal-sample, signal-delay, signal-throttle): Remove agenda parameter. * 2d/sprite.scm: * examples/common.scm: * examples/coroutine.scm: * examples/font.scm: * examples/particles.scm: Remove mention of game-agenda. * README.org: Update example snippets. --- README.org | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index d54895a..bbd26e0 100644 --- a/README.org +++ b/README.org @@ -152,7 +152,7 @@ exists a =wait= procedure to pause a coroutine and schedule it to be resumed later. - Using a coroutine and an agenda, the NPC script can be rewritten + Using a coroutine and the agenda, the NPC script can be rewritten such that it does not halt further program execution. #+BEGIN_SRC scheme @@ -163,19 +163,18 @@ (coroutine (while #t (walk 'up) - (wait game-agenda 60) + (wait 60) (walk 'down) - (wait game-agenda 60))) + (wait 60))) #+END_SRC =coroutine= is a useful macro that evaluates a block of code as a coroutine. =wait= aborts the procedure and schedules the - continuation inside of an agenda. =game-agenda= is the main - agenda that is ticked at each iteration of the game update loop. - In this example, the script is paused for 1 second after each - step. Since guile-2d enforces a fixed timestep and updates 60 - times per second by default, 60 ticks is equivalent to 1 second. + continuation inside of the agenda. In this example, the script is + paused for 1 second after each step. Since guile-2d enforces a + fixed timestep and updates 60 times per second by default, 60 + ticks is equivalent to 1 second. You can also use the agenda to schedule the evaluation of any thunk even if it isn't a coroutine. @@ -184,7 +183,7 @@ (define (hello) (display "Hello, world! Sorry I'm late!\n")) - (schedule game-agenda hello 600) + (schedule hello 600) #+END_SRC =schedule= accepts a thunk (a procedure that takes no arguments) @@ -220,7 +219,7 @@ (signal-fold v+ (vector2 320 240) (signal-map (lambda (v) (vscale v 4)) - (signal-sample game-agenda 1 key-arrows)))) + (signal-sample 1 key-arrows)))) #+END_SRC This signal describes a relationship between the arrow keys on the -- cgit v1.2.3