summaryrefslogtreecommitdiff
path: root/examples/coroutine.scm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/coroutine.scm')
-rw-r--r--examples/coroutine.scm18
1 files changed, 8 insertions, 10 deletions
diff --git a/examples/coroutine.scm b/examples/coroutine.scm
index 2bf7ecb..250cdbb 100644
--- a/examples/coroutine.scm
+++ b/examples/coroutine.scm
@@ -5,11 +5,16 @@
(2d agenda)
(2d coroutine))
-(init-2d)
-
(define window-width 800)
(define window-height 600)
-(define sprite #f)
+
+;; Open the window.
+(open-window window-width window-height)
+
+(define sprite
+ (load-sprite "images/sprite.png"
+ #:position (vector (/ window-width 2)
+ (/ window-height 2))))
(define (key-down key mod unicode)
(cond ((any-equal? key 'escape 'q)
@@ -24,13 +29,6 @@
(add-hook! on-render-hook (lambda () (render)))
(add-hook! on-key-down-hook (lambda (key mod unicode) (key-down key mod unicode)))
-;; Open the window.
-(open-window window-width window-height)
-
-;; Load a sprite and center it on the screen.
-(set! sprite (load-sprite "images/sprite.png" #:position (vector (/ window-width 2)
- (/ window-height 2))))
-
;; Simple script that moves the sprite to a random location every
;; second.
(agenda-schedule