diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-06-07 19:57:06 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-06-07 19:57:06 -0400 |
commit | c2a4f0636569978a40cb5c98875d798624909eb2 (patch) | |
tree | ca0d993826c0adde719e3a88aec255626281340d /examples | |
parent | def69615603e49bb17b09c7352295578f9dd67af (diff) |
Replace vector2 module with a more generic vector module.
* 2d/vector2.scm: Delete it.
* 2d/vector.scm: New file.
* Makefile.am (SOURCES): s/vector2/vector.
* 2d/font.scm:
* 2d/keyboard.scm:
* 2d/mouse.scm:
* 2d/rect.scm:
* 2d/shader.scm:
* 2d/sprite.scm:
* 2d/texture.scm:
* 2d/transform.scm:
* 2d/window.scm:
* examples/2048/2048:
* examples/animation.scm:
* examples/coroutine.scm:
* examples/font.scm:
* examples/particles.scm:
* examples/simple.scm:
* examples/tilemap.scm: Use vectors instead of defunct vector2.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/2048/2048 | 43 | ||||
-rw-r--r-- | examples/animation.scm | 4 | ||||
-rw-r--r-- | examples/coroutine.scm | 12 | ||||
-rw-r--r-- | examples/font.scm | 8 | ||||
-rw-r--r-- | examples/particles.scm | 16 | ||||
-rw-r--r-- | examples/simple.scm | 4 | ||||
-rw-r--r-- | examples/tilemap.scm | 8 |
7 files changed, 46 insertions, 49 deletions
diff --git a/examples/2048/2048 b/examples/2048/2048 index 53f32aa..58f2615 100755 --- a/examples/2048/2048 +++ b/examples/2048/2048 @@ -41,7 +41,7 @@ (2d signal) (2d sprite) (2d texture) - (2d vector2) + (2d vector) (2d window) (2d repl)) ;;; @@ -326,20 +326,15 @@ (h (texture-height tile-texture)) (background (make-sprite tile-texture - #:position (center - (vector2 - (* x w) - (* y h))) + #:position (center (vector (* x w) (* y h))) #:color (tile-bg-color n) - #:anchor null-vector2)) + #:anchor #(0 0))) (label (make-label font (if (zero? n) " " (number->string n)) (center - (vector2 (+ (* x w) - (/ w 2)) - (+ (* y h) - (/ h 2)))) + (vector (+ (* x w) (/ w 2)) + (+ (* y h) (/ h 2)))) #:color (tile-text-color n) #:anchor 'center))) (%make-tile background label))) @@ -355,8 +350,8 @@ (define board-height (* board-size (texture-height tile-texture))) (define center-pos - (vector2 (/ (- window-width board-width) 2) - (- window-height board-height 8))) + (vector (/ (- window-width board-width) 2) + (- window-height board-height 8))) (define (center v) (v+ v center-pos)) @@ -388,8 +383,8 @@ (else "")))) (make-label font message (center - (vector2 (/ board-width 2) - (/ board-height 2))) + (vector (/ board-width 2) + (/ board-height 2))) #:color black #:anchor 'bottom-center))) board)) @@ -405,8 +400,8 @@ "Press N to play again" "") (center - (vector2 (/ board-width 2) - (/ board-height 2))) + (vector (/ board-width 2) + (/ board-height 2))) #:color black #:anchor 'top-center)) board)) @@ -416,7 +411,7 @@ (define instructions (make-label instruction-font "Use the arrow keys to join the numbers and get to the 2048 tile!" - (vector2 (/ window-width 2) 0) + (vector (/ window-width 2) 0) #:color text-color-1 #:anchor 'top-center)) @@ -426,7 +421,7 @@ (define score-header (make-label score-header-font "SCORE" - (vector2 (+ (vx center-pos) (/ board-width 4)) 24) + (vector (+ (vx center-pos) (/ board-width 4)) 24) #:color text-color-1 #:anchor 'top-center)) @@ -435,8 +430,8 @@ (lambda (state) (make-label score-font (format #f "~d" (2048-score state)) - (vector2 (vx (label-position score-header)) - (+ (vy (label-position score-header)) 32)) + (vector (vx (label-position score-header)) + (+ (vy (label-position score-header)) 32)) #:color text-color-1 #:anchor 'center)) 2048-state)) @@ -444,7 +439,9 @@ (define best-score-header (make-label score-header-font "BEST" - (vector2 (+ (vx center-pos) (- board-width (/ board-width 4))) 24) + (vector (+ (vx center-pos) + (- board-width (/ board-width 4))) + 24) #:color text-color-1 #:anchor 'top-center)) @@ -453,8 +450,8 @@ (lambda (state) (make-label score-font (format #f "~d" (2048-best-score state)) - (vector2 (vx (label-position best-score-header)) - (+ (vy (label-position best-score-header)) 32)) + (vector (vx (label-position best-score-header)) + (+ (vy (label-position best-score-header)) 32)) #:color text-color-1 #:anchor 'center)) 2048-state)) diff --git a/examples/animation.scm b/examples/animation.scm index 8be77ef..873b2de 100644 --- a/examples/animation.scm +++ b/examples/animation.scm @@ -19,7 +19,7 @@ (2d game) (2d sprite) (2d tileset) - (2d vector2) + (2d vector) (2d window)) (load "common.scm") @@ -39,7 +39,7 @@ sprite out of it." (make-animation frames 6 #t))) (define sprite (make-sprite (make-demo-animation) - #:position (vector2 320 240))) + #:position #(320 240))) (add-hook! draw-hook (lambda (dt alpha) (draw-sprite sprite))) diff --git a/examples/coroutine.scm b/examples/coroutine.scm index 741b357..6db9623 100644 --- a/examples/coroutine.scm +++ b/examples/coroutine.scm @@ -21,7 +21,7 @@ (2d game) (2d sprite) (2d texture) - (2d vector2) + (2d vector) (2d window)) (load "common.scm") @@ -33,11 +33,11 @@ (define sprite (make-sprite texture - #:position (vector 320 240))) + #:position #(320 240))) (define (random-vector2) - (vector2 (random window-width) - (random window-height))) + (vector (random window-width) + (random window-height))) ;; Simple script that moves the sprite to a random location every ;; second. @@ -51,6 +51,6 @@ (add-hook! draw-hook (lambda (dt alpha) (draw-sprite sprite))) (with-window (make-window #:title "Coroutines" - #:resolution (vector2 window-width - window-height)) + #:resolution (vector window-width + window-height)) (start-game-loop)) diff --git a/examples/font.scm b/examples/font.scm index 8bcd90d..4a8412b 100644 --- a/examples/font.scm +++ b/examples/font.scm @@ -22,7 +22,7 @@ (2d game) (2d mouse) (2d signal) - (2d vector2) + (2d vector) (2d window)) (load "common.scm") @@ -32,18 +32,18 @@ (define font (load-default-font 18)) (define label (make-label font "The quick brown fox jumped over the lazy dog." - (vector2 320 240) #:anchor 'center)) + #(320 240) #:anchor 'center)) (define-signal fps-label (signal-map (lambda (fps) (let ((text (format #f "FPS: ~d" fps))) - (make-label font text (vector2 0 0)))) + (make-label font text #(0 0)))) fps)) (define-signal mouse-label (signal-map (lambda (p) (let ((text (format #f "Mouse: (~d, ~d)" (vx p) (vy p)))) - (make-label font text (vector2 0 20)))) + (make-label font text #(0 20)))) (signal-throttle 5 mouse-position))) (add-hook! draw-hook (lambda (dt alpha) diff --git a/examples/particles.scm b/examples/particles.scm index b60a537..8fa9cb6 100644 --- a/examples/particles.scm +++ b/examples/particles.scm @@ -21,7 +21,7 @@ (2d game) (2d sprite) (2d texture) - (2d vector2) + (2d vector) (2d window)) (load "common.scm") @@ -51,14 +51,14 @@ (let ((particle-image (load-texture "images/bullet.png"))) (list-tabulate n (lambda (n) (make-particle (make-sprite particle-image) - (vector2 (random window-width) - (random window-height)) - (vector2 (* (random:normal) 1) - (* (random:normal) 1))))))) + (vector (random window-width) + (random window-height)) + (vector (* (random:normal) 1) + (* (random:normal) 1))))))) (define particle-count 500) (define background (load-sprite "images/stars.png" - #:anchor null-vector2)) + #:anchor #(0 0))) (define particles (generate-particles particle-count)) (define (draw-particles particles) @@ -79,6 +79,6 @@ (add-hook! draw-hook draw) (with-window (make-window #:title "Particles" - #:resolution (vector2 window-width - window-height)) + #:resolution (vector window-width + window-height)) (start-game-loop)) diff --git a/examples/simple.scm b/examples/simple.scm index a2c1fa4..3f3c881 100644 --- a/examples/simple.scm +++ b/examples/simple.scm @@ -17,13 +17,13 @@ (use-modules (2d game) (2d sprite) - (2d vector2) + (2d vector) (2d window)) (load "common.scm") (define sprite (load-sprite "images/p1_front.png" - #:position (vector2 320 240))) + #:position #(320 240))) (add-hook! draw-hook (lambda (dt alpha) (draw-sprite sprite))) diff --git a/examples/tilemap.scm b/examples/tilemap.scm index 284c760..5c5abdf 100644 --- a/examples/tilemap.scm +++ b/examples/tilemap.scm @@ -22,7 +22,7 @@ (2d sprite) (2d texture) (2d tileset) - (2d vector2) + (2d vector) (2d window)) (load "common.scm") @@ -79,9 +79,9 @@ (define (build-sprite x y) (let ((region (tileset-ref tileset (array-ref tiles y x)))) (make-sprite region - #:position (vector2 (* x tile-width) - (* y tile-height)) - #:anchor null-vector2))) + #:position (vector (* x tile-width) + (* y tile-height)) + #:anchor #(0 0)))) (let ((sprites (list-ec (: y height) (list-ec (: x width) |