From f5abf968e86cbd55f5a79f8b6826eac42f93ee9f Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 15 Aug 2013 18:59:34 -0400 Subject: Update examples. --- examples/animation.scm | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'examples/animation.scm') diff --git a/examples/animation.scm b/examples/animation.scm index 1e478a3..d00a9df 100644 --- a/examples/animation.scm +++ b/examples/animation.scm @@ -6,11 +6,11 @@ (2d vector) (2d window)) -(init-2d) - (define window-width 800) (define window-height 600) -(define sprite #f) + +;; Open the window. +(open-window window-width window-height) (define (key-down key mod unicode) (cond ((any-equal? key 'escape 'q) @@ -25,23 +25,24 @@ (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 texture, split it into 64x64 tiles, and build an animated ;; sprite out of it. -(let* ((tiles (split-texture (load-texture "images/princess.png") 64 64)) - (frames (vector (vector-ref tiles 19) - (vector-ref tiles 20) - (vector-ref tiles 21) - (vector-ref tiles 22) - (vector-ref tiles 23) - (vector-ref tiles 24) - (vector-ref tiles 25) - (vector-ref tiles 26))) - (animation (make-animation frames 6 #t))) - (set! sprite (make-sprite animation - #:position (vector (/ window-width 2) - (/ window-height 2))))) +(define animation + (let* ((tiles (split-texture (load-texture "images/princess.png") 64 64)) + (frames (vector (vector-ref tiles 19) + (vector-ref tiles 20) + (vector-ref tiles 21) + (vector-ref tiles 22) + (vector-ref tiles 23) + (vector-ref tiles 24) + (vector-ref tiles 25) + (vector-ref tiles 26)))) + (make-animation frames 6 #t))) + +(define sprite + (make-sprite animation + #:position (vector (/ window-width 2) + (/ window-height 2)))) + (run-game-loop) -- cgit v1.2.3