summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-11-30 20:51:11 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-11-30 20:51:11 -0500
commit5b19db7c87120e612743c609cc9f52ccb4720f10 (patch)
tree24188ec7396584e32c9e65f811850589d12c1303
parentc8117dfb6aacf26e757ea797234f9ea23abdbb60 (diff)
examples: Update font example.
* examples/font.scm: Update.
-rw-r--r--examples/font.scm41
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: