From cbf6c67b45e4782a9308273972bec95e2e38a775 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 30 Nov 2014 19:22:43 -0500 Subject: examples: Update 2048. * examples/2048/2048: Use new group/model procedures. --- examples/2048/2048 | 56 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'examples') diff --git a/examples/2048/2048 b/examples/2048/2048 index b4e472e..ddf46df 100755 --- a/examples/2048/2048 +++ b/examples/2048/2048 @@ -323,14 +323,16 @@ (define (make-tile x y n) (let* ((w (texture-width tile-texture)) - (h (texture-height tile-texture))) - (apply move (vector2 (* x w) (* y h)) - (paint (tile-bg-color n) tile-sprite) + (h (texture-height tile-texture)) + (label (assoc-ref tile-label-cache n)) + (label-color (tile-text-color n)) + (bg-color (tile-bg-color n))) + (apply group-move (vector2 (* x w) (* y h)) + (model-paint bg-color tile-sprite) (if (zero? n) '() - (list (move (vector2 (/ w 2) (/ h 2)) - (paint (tile-text-color n) - (assoc-ref tile-label-cache n)))))))) + (list (group-move (vector2 (/ w 2) (/ h 2)) + (model-paint label-color label))))))) (define window-width 640) (define window-height 480) @@ -366,14 +368,14 @@ ((board-lose? board) "GAME OVER") ((board-win? board) "YOU WIN!") (else #f)))) - (apply move (vector2 (/ board-width 2) - (/ board-height 2)) + (apply group-move (vector2 (/ board-width 2) + (/ board-height 2)) (if message - (list (paint black (label font message - #:anchor 'bottom-center)) - (paint black (label play-again-font - "Press N to play again" - #:anchor 'top-center))) + (list (model-paint black (label font message + #:anchor 'bottom-center)) + (model-paint black (label play-again-font + "Press N to play again" + #:anchor 'top-center))) '())))) board)) @@ -383,10 +385,10 @@ "Use the arrow keys to join the numbers and get to the 2048 tile!") (define-signal instructions - (move (vector2 (/ board-width 2) (- window-height (vy center-pos))) - (paint text-color-1 - (label instruction-font instruction-text - #:anchor 'top-center)))) + (group-move (vector2 (/ board-width 2) (- window-height (vy center-pos))) + (model-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)) @@ -398,16 +400,16 @@ (tween vlerp ease-linear from to duration))) (color-tween (tween color-lerp ease-linear transparent text-color-1 duration)) - (score (signal-drop-repeats score))) + (score (signal-drop-repeats score)) + (header (label score-header-font text #:anchor 'top-center))) (signal-map (lambda (score timer) - (move (vector2 x (- window-height 28)) - (paint text-color-1 - (label score-header-font text - #:anchor 'top-center)) - (move (position-tween timer) - (paint (color-tween timer) - (label score-font (number->string score) - #:anchor 'center))))) + (let ((score (label score-font (number->string score) + #:anchor 'center))) + (group-move (vector2 x (- window-height 28)) + (model-paint text-color-1 header) + (group-move (position-tween timer) + (model-paint (color-tween timer) + score))))) score (signal-drop (lambda (t) (> t duration)) 0 (signal-since 1 score))))) @@ -420,7 +422,7 @@ (- board-width (/ board-width 4)))) (define-signal 2048-scene - (signal-map (cut move center-pos <>) + (signal-map (cut group-move center-pos <>) (signal-map group instructions tiles score best-score status-message))) -- cgit v1.2.3