summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-08-27 18:22:06 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-08-27 18:22:06 -0400
commit5841889f53465b4096830f3778b209063e1fe8bc (patch)
tree724087d4dbfeb08349401d7ff19e0f099a550667 /examples
parente719d1e988617f623fac29c1bd347785833c5f71 (diff)
Replace old vector module with new vector2 module.
Diffstat (limited to 'examples')
-rw-r--r--examples/action.scm8
-rw-r--r--examples/animation.scm26
-rw-r--r--examples/coroutine.scm11
-rw-r--r--examples/font.scm5
-rw-r--r--examples/particles.scm12
-rw-r--r--examples/simple.scm7
-rw-r--r--examples/tilemap.scm9
7 files changed, 40 insertions, 38 deletions
diff --git a/examples/action.scm b/examples/action.scm
index e5dce93..dab15c1 100644
--- a/examples/action.scm
+++ b/examples/action.scm
@@ -5,7 +5,7 @@
(2d agenda)
(2d coroutine)
(2d actions)
- (2d vector))
+ (2d vector2))
(define window-width 800)
(define window-height 600)
@@ -16,8 +16,8 @@
;; Load a sprite and center it on the screen.
(define sprite
(load-sprite "images/sprite.png"
- #:position (vector (/ window-width 2)
- (/ window-height 2))))
+ #:position (vector2 (/ window-width 2)
+ (/ window-height 2))))
(define (key-down key mod unicode)
(cond ((any-equal? key 'escape 'q)
@@ -36,7 +36,7 @@
(action-parallel
;; Move horizontally across the screen in 60 frames.
(lerp (lambda (x)
- (set-sprite-position! sprite (vector x (/ window-height 2))))
+ (set-sprite-position! sprite (vector2 x (/ window-height 2))))
0 800 60)
;; Rotate 1080 degrees in 120 frames.
(lerp (lambda (angle)
diff --git a/examples/animation.scm b/examples/animation.scm
index d00a9df..0e58b8e 100644
--- a/examples/animation.scm
+++ b/examples/animation.scm
@@ -2,8 +2,8 @@
(2d game-loop)
(2d helpers)
(2d sprite)
- (2d texture)
- (2d vector)
+ (2d tileset)
+ (2d vector2)
(2d window))
(define window-width 800)
@@ -28,21 +28,21 @@
;; Load a texture, split it into 64x64 tiles, and build an animated
;; sprite out of it.
(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))))
+ (let* ((tiles (load-tileset "images/princess.png" 64 64))
+ (frames (vector (tileset-ref tiles 19)
+ (tileset-ref tiles 20)
+ (tileset-ref tiles 21)
+ (tileset-ref tiles 22)
+ (tileset-ref tiles 23)
+ (tileset-ref tiles 24)
+ (tileset-ref tiles 25)
+ (tileset-ref tiles 26))))
(make-animation frames 6 #t)))
(define sprite
(make-sprite animation
- #:position (vector (/ window-width 2)
- (/ window-height 2))))
+ #:position (vector2 (/ window-width 2)
+ (/ window-height 2))))
(run-game-loop)
diff --git a/examples/coroutine.scm b/examples/coroutine.scm
index 250cdbb..0a4d000 100644
--- a/examples/coroutine.scm
+++ b/examples/coroutine.scm
@@ -3,7 +3,8 @@
(2d window)
(2d helpers)
(2d agenda)
- (2d coroutine))
+ (2d coroutine)
+ (2d vector2))
(define window-width 800)
(define window-height 600)
@@ -13,8 +14,8 @@
(define sprite
(load-sprite "images/sprite.png"
- #:position (vector (/ window-width 2)
- (/ window-height 2))))
+ #:position (vector2 (/ window-width 2)
+ (/ window-height 2))))
(define (key-down key mod unicode)
(cond ((any-equal? key 'escape 'q)
@@ -34,8 +35,8 @@
(agenda-schedule
(colambda ()
(while #t
- (set-sprite-position! sprite (vector (random window-width)
- (random window-height)))
+ (set-sprite-position! sprite (vector2 (random window-width)
+ (random window-height)))
(wait 60))))
(run-game-loop)
diff --git a/examples/font.scm b/examples/font.scm
index 8cdfd3a..69da60a 100644
--- a/examples/font.scm
+++ b/examples/font.scm
@@ -3,13 +3,14 @@
(2d game-loop)
(2d window)
(2d helpers)
- (2d font))
+ (2d font)
+ (2d vector2))
(define window-width 800)
(define window-height 600)
(define font (load-font "fonts/Boxy-Bold.ttf" 48))
(define text "The quick brown fox jumped over the lazy dog.")
-(define textbox (make-textbox font text #(320 300) white 'left 200))
+(define textbox (make-textbox font text (vector2 320 300) white 'left 200))
;; Open the window.
(open-window window-width window-height)
diff --git a/examples/particles.scm b/examples/particles.scm
index 5251ac0..dfe3322 100644
--- a/examples/particles.scm
+++ b/examples/particles.scm
@@ -5,7 +5,7 @@
(2d helpers)
(2d sprite)
(2d texture)
- (2d vector)
+ (2d vector2)
(2d window))
(set! *random-state* (random-state-from-platform))
@@ -35,7 +35,7 @@
(open-window window-width window-height)
-(define stars (load-sprite "images/stars.png" #:anchor #(0 0)))
+(define stars (load-sprite "images/stars.png" #:anchor null-vector2))
(define particle-image (load-texture "images/bullet.png"))
(define particle-width (texture-width particle-image))
(define particle-height (texture-height particle-image))
@@ -44,10 +44,10 @@
(list-tabulate particle-count
(lambda (n)
(make-particle (make-sprite particle-image)
- (vector (random window-width)
- (random window-height))
- (vector (* (random:normal) 1)
- (* (random:normal) 1))))))
+ (vector2 (random window-width)
+ (random window-height))
+ (vector2 (* (random:normal) 1)
+ (* (random:normal) 1))))))
(define batch (make-sprite-batch (* particle-count 4)))
(define (draw-particles particles)
diff --git a/examples/simple.scm b/examples/simple.scm
index e5f5ae0..6a4e928 100644
--- a/examples/simple.scm
+++ b/examples/simple.scm
@@ -1,7 +1,8 @@
(use-modules (2d sprite)
(2d game-loop)
(2d window)
- (2d helpers))
+ (2d helpers)
+ (2d vector2))
(define window-width 800)
(define window-height 600)
@@ -11,8 +12,8 @@
(define sprite
(load-sprite "images/sprite.png"
- #:position (vector (/ window-width 2)
- (/ window-height 2))))
+ #:position (vector2 (/ window-width 2)
+ (/ window-height 2))))
(define (quit-demo)
(close-window)
diff --git a/examples/tilemap.scm b/examples/tilemap.scm
index 3d15049..b64c04e 100644
--- a/examples/tilemap.scm
+++ b/examples/tilemap.scm
@@ -6,7 +6,7 @@
(2d texture)
(2d tileset)
(2d sprite)
- (2d vector)
+ (2d vector2)
(2d window))
(define window-width 800)
@@ -55,7 +55,6 @@
(define tile-width 32)
(define tile-height 32)
-(define map #f)
(define (random-map width height tileset)
(let ((tiles (make-array 0 height width))
@@ -68,9 +67,9 @@
(define (build-sprite x y)
(let ((region (tileset-ref tileset (array-ref tiles y x))))
(make-sprite region
- #:position (vector (* x tile-width)
- (* y tile-height))
- #:anchor #(0 0))))
+ #:position (vector2 (* x tile-width)
+ (* y tile-height))
+ #:anchor null-vector2)))
(let ((sprites (list-ec (: y height)
(list-ec (: x width)