diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/font.scm | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/examples/font.scm b/examples/font.scm index bd19807..177879e 100644 --- a/examples/font.scm +++ b/examples/font.scm @@ -15,41 +15,52 @@ ;;; along with this program. If not, see ;;; <http://www.gnu.org/licenses/>. -(use-modules (sly agenda) +(use-modules (sly game) (sly fps) + (sly signal) + (sly window) + (sly math vector) + (sly render camera) (sly render color) (sly render font) - (sly game) - (sly input mouse) - (sly signal) - (sly vector) - (sly window)) + (sly render model) + (sly render group) + (sly input mouse)) (load "common.scm") (enable-fonts) (define font (load-default-font 18)) -(define label - (make-label font "The quick brown fox jumped over the lazy dog." - #(320 240) #:anchor 'center)) + +(define-signal message-label + (group-move (vector2 320 240) + (group + (label font "The quick brown fox jumped over the lazy dog." + #:anchor 'center)))) (define-signal fps-label (signal-map (lambda (fps) (let ((text (format #f "FPS: ~d" fps))) - (make-label font text #(0 0)))) + (group-move (vector2 0 480) (group (label font text))))) fps)) (define-signal mouse-label (signal-map (lambda (p) (let ((text (format #f "Mouse: (~d, ~d)" (vx p) (vy p)))) - (make-label font text #(0 20)))) + (group-move (vector2 0 460) (group (label font text))))) (signal-throttle 5 mouse-position))) -(add-hook! draw-hook (lambda (dt alpha) - (draw-label label) - (draw-label (signal-ref fps-label)) - (draw-label (signal-ref mouse-label)))) +(define-signal scene + (signal-map group message-label fps-label mouse-label)) + +(define camera (orthographic-camera 640 480)) + +(add-hook! draw-hook (lambda _ (draw-group (signal-ref scene) camera))) (with-window (make-window #:title "Fonts") (start-game-loop)) + +;;; Local Variables: +;;; compile-command: "../pre-inst-env guile font.scm" +;;; End: |