diff options
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 |