summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/action.scm12
-rw-r--r--examples/animation.scm6
2 files changed, 7 insertions, 11 deletions
diff --git a/examples/action.scm b/examples/action.scm
index 2886c0a..9f4dd65 100644
--- a/examples/action.scm
+++ b/examples/action.scm
@@ -8,31 +8,29 @@
(2d stage)
(2d vector2))
-(define (demo-sprite)
+(define-stage-variable sprite
(load-sprite "images/ghost.png"
#:position (vector2 320 240)))
(define (init)
- (let ((size (game-resolution actions-demo))
- (sprite (demo-sprite)))
- (stage-define sprite sprite)
+ (let ((size (game-resolution actions-demo)))
(schedule-action
(action-parallel
;; Move horizontally across the screen in 60 frames.
(lerp (lambda (x)
(set-sprite-position!
- sprite
+ (sprite)
(vector2 x (/ (vy size) 2))))
0 (vx size) 120)
;; Rotate 1080 degrees in 120 frames.
(lerp (lambda (angle)
- (set-sprite-rotation! sprite angle))
+ (set-sprite-rotation! (sprite) angle))
0 360 120)))))
(define demo-scene
(make-scene
#:init init
- #:draw (lambda () (draw-sprite (stage-ref sprite)))))
+ #:draw (lambda () (draw-sprite (sprite)))))
(define actions-demo
(make-game
diff --git a/examples/animation.scm b/examples/animation.scm
index bf43be9..92da549 100644
--- a/examples/animation.scm
+++ b/examples/animation.scm
@@ -22,16 +22,14 @@ sprite out of it."
(tileset-ref tiles 26))))
(make-animation frames 6 #t)))
-(define (demo-sprite)
+(define-stage-variable sprite
(make-sprite (demo-animation)
#:position (vector2 320 240)))
(define demo-scene
(make-scene
- #:init (lambda ()
- (stage-define sprite (demo-sprite)))
#:draw (lambda ()
- (draw-sprite (stage-ref sprite)))))
+ (draw-sprite (sprite)))))
(define animation-demo
(make-game