summaryrefslogtreecommitdiff
path: root/examples/coroutine.scm
diff options
context:
space:
mode:
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)