summaryrefslogtreecommitdiff
path: root/examples/2048
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-03-09 08:52:14 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-03-09 08:58:42 -0400
commitd84bb24d2359be9c4be7b3e4f05caf3daf68f243 (patch)
treed57b082948ef75bdd0f9cc5d1c15a8d70d784d26 /examples/2048
parent8ac70ff3cef2963c460ce5382e37946eb0a4914e (diff)
render: Merge <group> into <model>.
* sly/render/model.scm (<model>): Add 'transform' and 'children' fields. (model-transform, model-children): New accessors. (make-model): Add 'transform' and 'children' keyword arguments. (set-transform-identity!): New procedure. (draw-model): Recursively draw model and all children. (model-paint, model-blend): Renamed. (paint, blend, group, group*, move, place): New procedures. * sly/render/group.scm: Delete. * Makefile.am (SOURCES): Remove it. * examples/2048/2048.scm: Update example. * examples/animation.scm: Likewise. * examples/font.scm: Likewise. * examples/joystick.scm: Likewise. * examples/mines/mines.scm: Likewise. * examples/simple.scm: Likewise. * examples/tilemap.scm: Likewise. * README.org (Example): Update sample code.
Diffstat (limited to 'examples/2048')
-rwxr-xr-xexamples/2048/2048.scm72
1 files changed, 36 insertions, 36 deletions
diff --git a/examples/2048/2048.scm b/examples/2048/2048.scm
index 73cb5f6..7bffe0b 100755
--- a/examples/2048/2048.scm
+++ b/examples/2048/2048.scm
@@ -37,7 +37,6 @@
(sly render color)
(sly render context)
(sly render font)
- (sly render group)
(sly render model)
(sly render sprite)
(sly render texture)
@@ -324,14 +323,15 @@
(label (assoc-ref tile-label-cache n))
(label-color (tile-text-color n))
(bg-color (tile-bg-color n)))
- (group-move (vector2 (* x w) (* y h))
- (make-group
- (cons (model-paint bg-color tile-sprite)
- (if (zero? n)
- '()
- (list (group-move (vector2 (/ w 2) (/ h 2))
- (group (model-paint label-color
- label))))))))))
+ (move (vector2 (* x w) (* y h))
+ (group*
+ (cons (paint bg-color tile-sprite)
+ (if (zero? n)
+ '()
+ (list (move (vector2 (/ w 2) (/ h 2))
+ (group
+ (paint label-color
+ label))))))))))
(define window-width 640)
(define window-height 480)
@@ -347,7 +347,7 @@
(define-signal tiles
(signal-map (lambda (board)
- (make-group
+ (group*
(append-map
(match-lambda
((y (row ...))
@@ -361,24 +361,24 @@
(define play-again-font (load-default-font 16))
(define-signal status-message
- (let ((play-again (model-paint black (label play-again-font
- "Press N to play again"
- #:anchor 'top-center)))
- (game-over (model-paint black (label font "GAME OVER"
- #:anchor 'bottom-center)))
- (you-win (model-paint black (label font "YOU WIN!"
- #:anchor 'bottom-center))))
+ (let ((play-again (paint black (label play-again-font
+ "Press N to play again"
+ #:anchor 'top-center)))
+ (game-over (paint black (label font "GAME OVER"
+ #:anchor 'bottom-center)))
+ (you-win (paint black (label font "YOU WIN!"
+ #:anchor 'bottom-center))))
(signal-map
(lambda (board)
(let ((message (cond
((board-lose? board) game-over)
((board-win? board) you-win)
(else #f))))
- (group-move (vector2 (/ board-width 2)
- (/ board-height 2))
- (make-group (if message
- (list message play-again)
- '())))))
+ (move (vector2 (/ board-width 2)
+ (/ board-height 2))
+ (group* (if message
+ (list message play-again)
+ '())))))
board)))
(define instruction-font (load-default-font 16))
@@ -387,11 +387,11 @@
"Use the arrow keys to join the numbers and get to the 2048 tile!")
(define-signal instructions
- (group-move (vector2 (/ board-width 2) (- window-height (vy center-pos)))
- (group
- (model-paint text-color-1
- (label instruction-font instruction-text
- #:anchor 'top-center)))))
+ (move (vector2 (/ board-width 2) (- window-height (vy center-pos)))
+ (group
+ (paint text-color-1
+ (label instruction-font instruction-text
+ #:anchor 'top-center)))))
(define score-header-font (load-default-font 14))
(define score-font (load-default-font 22))
@@ -408,13 +408,13 @@
(signal-map (lambda (score timer)
(let ((score (label score-font (number->string score)
#:anchor 'center)))
- (group-move (vector2 x (- window-height 28))
- (group
- (model-paint text-color-1 header)
- (group-move (position-tween timer)
- (group
- (model-paint (color-tween timer)
- score)))))))
+ (move (vector2 x (- window-height 28))
+ (group
+ (paint text-color-1 header)
+ (move (position-tween timer)
+ (group
+ (paint (color-tween timer)
+ score)))))))
score
(signal-drop (lambda (t) (> t duration))
0 (signal-since 1 score)))))
@@ -427,7 +427,7 @@
(- board-width (/ board-width 4))))
(define-signal 2048-scene
- (signal-map (cut group-move center-pos <>)
+ (signal-map (cut move center-pos <>)
(signal-map group instructions tiles score
best-score status-message)))
@@ -438,7 +438,7 @@
(define (draw-2048 dt alpha)
(signal-let ((scene 2048-scene))
- (draw-group scene camera)))
+ (draw-model scene camera)))
;;;
;;; Initialization