From 777e31518c8ae52e9e15867fb60c958fa7a15610 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 3 Nov 2013 20:03:07 -0500 Subject: Update examples to use new scene/stage system. --- examples/coroutine.scm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'examples/coroutine.scm') 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) -- cgit v1.2.3