From 6ba2755dd1ba3bcb1de88799284e908cf7f42b3a Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 29 Jan 2018 19:16:19 -0500 Subject: Add tile map example. * examples/images/tiles.png: New file. * examples/map/example.tmx: New file. * examples/tiled.scm: New file. * Makefile.am (EXTRA_DIST): Add them. * examples/images/AUTHORS: Credit the author of the tileset. --- examples/images/AUTHORS | 4 ++ examples/images/tiles.png | Bin 0 -> 100846 bytes examples/maps/example.tmx | 96 ++++++++++++++++++++++++++++++++++++++++++++++ examples/tiled.scm | 31 +++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 examples/images/tiles.png create mode 100644 examples/maps/example.tmx create mode 100644 examples/tiled.scm (limited to 'examples') diff --git a/examples/images/AUTHORS b/examples/images/AUTHORS index 58442fd..985a963 100644 --- a/examples/images/AUTHORS +++ b/examples/images/AUTHORS @@ -7,3 +7,7 @@ * dialog-box.png By DragonDePlatino, CC BY-SA 3.0 http://opengameart.org/content/dawnlike-16x16-universal-rogue-like-tileset-v181 + +* tiles.png + By ArMM1998, CC0 + https://opengameart.org/content/zelda-like-tilesets-and-sprites diff --git a/examples/images/tiles.png b/examples/images/tiles.png new file mode 100644 index 0000000..d8a3dfd Binary files /dev/null and b/examples/images/tiles.png differ diff --git a/examples/maps/example.tmx b/examples/maps/example.tmx new file mode 100644 index 0000000..6c8bc3d --- /dev/null +++ b/examples/maps/example.tmx @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1175,1176,1176,1177,1, +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1215,1216,1216,1217,1, +1,1,1,1,1,1175,1176,1177,1,1,1,1,1,1,1,1215,1216,1216,1217,1, +1,1,1,1175,1176,1336,1216,1335,1177,1,1,1,1,1,1,1255,1296,1216,1217,1, +1,1,1,1215,1216,1216,1216,1216,1335,1177,1,1,1,1,1,1,1215,1216,1217,1, +1,1,1,1215,1216,1216,1216,1216,1216,1335,1176,1176,1176,1176,1177,1,1255,1256,1257,1, +1,1,1,1215,1216,1216,1216,1295,1296,1216,1216,1216,1216,1216,1217,1,1,1,1,1, +1,1,1,1255,1296,1216,1216,1217,1255,1256,1296,1216,1295,1256,1257,1,1,1,1,1, +1,1,1,1,1255,1256,1256,1257,1,367,1255,1256,1257,365,1,1,1,1,1,1, +446,446,446,446,446,446,446,446,446,447,212,253,253,445,446,446,446,446,446,446, +486,486,486,486,486,486,486,486,486,527,252,213,213,525,486,486,486,486,486,526, +566,566,566,566,566,566,566,566,566,567,252,253,253,565,566,566,566,566,566,566, +1,1,1,1,1,1,1,1,1,1,1175,1176,1177,1,1,1,1,1,1,1, +1,1,1,1,1,1,1,1,1,1,1215,1216,1335,1177,1,1,1,1,1,1 + + + + +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,646,647,0,0,0,0, +0,646,647,483,0,0,484,321,0,7,8,9,10,11,686,687,0,0,0,0, +0,686,687,0,444,0,827,0,321,47,48,49,50,51,0,0,0,0,0,0, +0,321,0,484,0,828,867,829,0,87,88,89,90,91,0,0,0,0,0,0, +0,0,483,0,0,868,0,869,0,127,128,129,130,131,646,647,0,0,0,0, +0,483,483,321,0,0,0,0,0,167,168,169,170,171,686,687,0,0,646,647, +0,0,444,0,0,0,0,0,73,0,0,0,0,0,483,0,484,0,686,687, +646,647,321,0,0,0,0,0,113,0,0,0,0,0,73,444,483,0,0,0, +686,687,483,0,484,321,484,0,444,0,528,0,0,0,113,483,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,116,0,0,0,0,0,0, +606,606,606,606,606,606,606,606,606,322,608,0,0,605,606,606,606,606,606,606, +0,0,0,0,0,0,0,0,483,484,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,450,451,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,490,491,0,0,0,0,0,45,46,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,86,0,0,0,0 + + + diff --git a/examples/tiled.scm b/examples/tiled.scm new file mode 100644 index 0000000..9e42301 --- /dev/null +++ b/examples/tiled.scm @@ -0,0 +1,31 @@ +(use-modules (chickadee) + (chickadee math vector) + (chickadee math rect) + (chickadee render tiled) + (ice-9 match)) + +(define map #f) +(define camera (vec2 0.0 0.0)) + +(define (load) + (set! map (load-tile-map "maps/example.tmx"))) + +(define (draw alpha) + (draw-tile-map map #:position camera)) + +(define inc 8.0) +(define (key-press key scancode modifiers repeat?) + (match key + ('up (set-vec2-y! camera (- (vec2-y camera) inc))) + ('down (set-vec2-y! camera (+ (vec2-y camera) inc))) + ('right (set-vec2-x! camera (- (vec2-x camera) inc))) + ('left (set-vec2-x! camera (+ (vec2-x camera) inc))) + ('q (abort-game)) + (_ #t))) + +(add-hook! load-hook load) +(add-hook! draw-hook draw) +(add-hook! key-press-hook key-press) +(add-hook! quit-hook abort-game) + +(run-game #:window-width 320 #:window-height 240 #:window-title "tile map demo") -- cgit v1.2.3