summaryrefslogtreecommitdiff
path: root/examples/animation.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-08-15 18:59:34 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-08-15 18:59:34 -0400
commitf5abf968e86cbd55f5a79f8b6826eac42f93ee9f (patch)
tree0108292950e8d5b1ed9c459399f83409acfc59aa /examples/animation.scm
parent8748076e491ac5500c7b05248c6ad1c14458b937 (diff)
Update examples.
Diffstat (limited to 'examples/animation.scm')
-rw-r--r--examples/animation.scm39
1 files changed, 20 insertions, 19 deletions
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)