diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-05-04 14:03:00 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-05-04 14:39:38 -0400 |
commit | d0ff41fb7a33c096a792ab57f5bbf7992b1cc399 (patch) | |
tree | 4b9bd31e0fd6ae71245892a353af83628372e63e /README.org | |
parent | c2a7defe0d13b20e50dbaf8aa48ffef5f65de65b (diff) |
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.
Diffstat (limited to 'README.org')
-rw-r--r-- | README.org | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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 |