summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-06-04 17:12:36 -0400
committerDavid Thompson <dthompson2@worcester.edu>2019-06-04 17:12:36 -0400
commit9d050e6ba7c40c8ed92aa1eeab7a98d89ca85970 (patch)
tree54065f8904533fb9d3c8e894cbdebc3513f0f3dc /examples
parent3da34ff5fea10d783711a63d8f53851ce633600d (diff)
render: tiled: Add point->tile.
* chickadee/render/tiled.scm (point->tile): New procedure. * doc/api.texi (Tiled): Document it. * examples/tiled.scm: Render tile coordinates in bottom-left corner.
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)