diff options
Diffstat (limited to 'examples/font.scm')
-rw-r--r-- | examples/font.scm | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/examples/font.scm b/examples/font.scm index 64d32e0..f5b4a0d 100644 --- a/examples/font.scm +++ b/examples/font.scm @@ -19,6 +19,7 @@ (sly fps) (sly signal) (sly window) + (sly math rect) (sly math vector) (sly render) (sly render camera) @@ -30,36 +31,34 @@ (load "common.scm") -(define font (load-default-font 18)) - (define camera (2d-camera #:area (make-rect 0 0 640 480))) -(define-signal render-message - (move (vector2 320 240) - (render-sprite - (make-label font "The quick brown fox jumped over the lazy dog." - #:anchor 'center)))) - -(define-signal render-fps - (signal-let ((fps fps)) - (let ((text (format #f "FPS: ~d" fps))) - (move (vector2 0 480) - (render-sprite (make-label font text)))))) +(define (render-messages font fps pos) + (render-begin + (move (vector2 320 240) + (render-sprite + (make-label font "The quick brown fox jumped over the lazy dog." + #:anchor 'center))) + (let ((text (format #f "FPS: ~d" fps))) + (move (vector2 0 480) + (render-sprite (make-label font text)))) + (let ((text (format #f "Mouse: (~d, ~d)" (vx pos) (vy pos)))) + (move (vector2 0 460) + (render-sprite (make-label font text)))))) -(define-signal render-mouse - (signal-let ((pos (signal-throttle 10 mouse-position))) - (let ((text (format #f "Mouse: (~d, ~d)" (vx pos) (vy pos)))) - (move (vector2 0 460) - (render-sprite (make-label font text)))))) +(define-signal font (on-start (load-default-font 18))) (define-signal scene - (signal-let ((message render-message) - (fps render-fps) - (mouse render-mouse)) + (signal-let ((fps fps) + (mouse-position (signal-throttle 10 mouse-position)) + (font font)) (with-camera camera - (render-begin message fps mouse)))) + (if font + (render-messages font fps mouse-position) + render-nothing)))) (with-window (make-window #:title "Fonts") + (enable-fonts) (run-game-loop scene)) ;;; Local Variables: |