diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-02-06 21:18:32 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-02-06 21:18:32 -0500 |
commit | 3267fc1ace530a37fecd05d0838809c6f0af22a7 (patch) | |
tree | 0b3bca668da67ad3acb6a87b12a139e870909734 /examples | |
parent | 21ff408c45685afacd3c0fffb3f81c46e9b00874 (diff) |
Add new coroutine macro.
* 2d/coroutine.scm (call-with-coroutine): New name for coroutine.
(coroutine): New macro.
(colambda, codefine, codefine*): Use call-with-coroutine.
* examples/coroutine.scm: Use coroutine macro.
* README.org: Update coroutine and agenda examples.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/coroutine.scm | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/examples/coroutine.scm b/examples/coroutine.scm index a479a66..45e8b39 100644 --- a/examples/coroutine.scm +++ b/examples/coroutine.scm @@ -15,17 +15,15 @@ ;; Simple script that moves the sprite to a random location every ;; second. -(codefine (script) - (set-sprite-position! - sprite - (vector2 (random window-width) - (random window-height))) - (wait game-agenda 15) - (set-sprite-rotation! sprite (random 360)) - (wait game-agenda 15) - (script)) - -(schedule game-agenda script) +(coroutine + (while #t + (set-sprite-position! + sprite + (vector2 (random window-width) + (random window-height))) + (wait game-agenda 15) + (set-sprite-rotation! sprite (random 360)) + (wait game-agenda 15))) (add-hook! draw-hook (lambda (dt alpha) (draw-sprite sprite))) |