summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/tiled.scm17
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/tiled.scm b/examples/tiled.scm
index 5ff2b7f..e6099df 100644
--- a/examples/tiled.scm
+++ b/examples/tiled.scm
@@ -1,17 +1,23 @@
(use-modules (chickadee)
(chickadee math vector)
(chickadee math rect)
+ (chickadee render font)
(chickadee render tiled)
- (ice-9 match))
+ (ice-9 format)
+ (ice-9 match)
+ (srfi srfi-11))
(define map #f)
(define camera #v(0.0 0.0))
+(define text-position #v(4.0 4.0))
+(define text "0, 0")
(define (load)
(set! map (load-tile-map "maps/example.tmx")))
(define (draw alpha)
- (draw-tile-map map #:position camera))
+ (draw-tile-map map #:position camera)
+ (draw-text text text-position))
(define inc 8.0)
(define (key-press key scancode modifiers repeat?)
@@ -23,9 +29,14 @@
('q (abort-game))
(_ #t)))
+(define (mouse-move x y x-rel y-rel buttons)
+ (let-values (((tx ty) (point->tile map x y)))
+ (set! text (format #f "~d, ~d" tx ty))))
+
(run-game #:window-width 320
#:window-height 240
#:window-title "tile map demo"
#:load load
#:draw draw
- #:key-press key-press)
+ #:key-press key-press
+ #:mouse-move mouse-move)