summaryrefslogtreecommitdiff
path: root/examples/coroutine.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-11-03 20:03:07 -0500
committerDavid Thompson <dthompson2@worcester.edu>2013-11-03 20:03:07 -0500
commit777e31518c8ae52e9e15867fb60c958fa7a15610 (patch)
tree873b2cec6608ef62bbc4e9ecae85d31fe4bf6cc4 /examples/coroutine.scm
parent49f93e5fe7261dd520a0013508fd02086af6ae17 (diff)
Update examples to use new scene/stage system.
Diffstat (limited to 'examples/coroutine.scm')
-rw-r--r--examples/coroutine.scm23
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/coroutine.scm b/examples/coroutine.scm
index 2f9b0ae..bdfc973 100644
--- a/examples/coroutine.scm
+++ b/examples/coroutine.scm
@@ -7,31 +7,30 @@
(2d stage)
(2d vector2))
-(define (demo-sprite)
- (load-sprite "images/ghost.png"
- #:position (vector2 320 240)))
-
-(define (init)
+(define (enter sprite)
;; Simple script that moves the sprite to a random location every
;; second.
- (stage-define sprite (demo-sprite))
(agenda-schedule
(colambda ()
(while #t
(set-sprite-position!
- (stage-ref sprite)
+ sprite
(vector2 (random (vx (game-resolution coroutine-demo)))
(random (vy (game-resolution coroutine-demo)))))
(wait 60)))))
-(define demo-scene
+(define coroutine-scene
(make-scene
- #:init init
- #:draw (lambda () (draw-sprite (stage-ref sprite)))))
+ "Coroutine"
+ #:init (lambda ()
+ (load-sprite "images/ghost.png"
+ #:position (vector2 320 240)))
+ #:enter enter
+ #:draw draw-sprite))
(define coroutine-demo
(make-game
- #:title "Coroutines"
- #:first-scene demo-scene))
+ #:title "Coroutines"
+ #:first-scene coroutine-scene))
(run-game coroutine-demo)