diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-01-29 19:16:19 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-01-29 22:31:31 -0500 |
commit | 6ba2755dd1ba3bcb1de88799284e908cf7f42b3a (patch) | |
tree | 03d0ca3f8f658e77058d1ca6a94904336bea74ba /examples | |
parent | 9c99fc7d12a5c90555b649ed845ab28d6a1b174c (diff) |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/images/AUTHORS | 4 | ||||
-rw-r--r-- | examples/images/tiles.png | bin | 0 -> 100846 bytes | |||
-rw-r--r-- | examples/maps/example.tmx | 96 | ||||
-rw-r--r-- | examples/tiled.scm | 31 |
4 files changed, 131 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..d8a3dfd --- /dev/null +++ b/examples/images/tiles.png 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<map version="1.0" tiledversion="1.1.0" orientation="orthogonal" renderorder="right-up" width="20" height="15" tilewidth="16" tileheight="16" infinite="0" nextobjectid="1"> + <tileset firstgid="1" name="tiles" tilewidth="16" tileheight="16" tilecount="1440" columns="40"> + <image source="../images/tiles.png" width="640" height="576"/> + <terraintypes> + <terrain name="grass" tile="0"/> + <terrain name="dark-grass" tile="1"/> + <terrain name="tree" tile="1"/> + <terrain name="nothing" tile="1"/> + </terraintypes> + <tile id="0" terrain="0,0,0,0"/> + <tile id="360" terrain="0,0,0,1"/> + <tile id="361" terrain="0,0,1,0"/> + <tile id="400" terrain="0,1,0,0"/> + <tile id="401" terrain="1,0,0,0"/> + <tile id="642" terrain="2,2,2,2"/> + <tile id="643" terrain="3,2,2,2"/> + <tile id="644" terrain="2,3,2,2"/> + <tile id="645" terrain="3,3,3,2"/> + <tile id="646" terrain="3,3,2,3"/> + <tile id="648" terrain="3,3,3,3"/> + <tile id="685" terrain="3,2,3,3"/> + <tile id="686" terrain="2,3,3,3"/> + <tile id="725" terrain="3,3,2,2"/> + <tile id="1174" terrain="0,0,0,1"/> + <tile id="1175" terrain="0,0,1,1"/> + <tile id="1176" terrain="0,0,1,0"/> + <tile id="1214" terrain="0,1,0,1"/> + <tile id="1215" terrain="1,1,1,1"/> + <tile id="1216" terrain="1,0,1,0"/> + <tile id="1254" terrain="0,1,0,0"/> + <tile id="1255" terrain="1,1,0,0"/> + <tile id="1256" terrain="1,0,0,0"/> + <tile id="1294" terrain="1,1,1,0"/> + <tile id="1295" terrain="1,1,0,1"/> + <tile id="1334" terrain="1,0,1,1"/> + <tile id="1335" terrain="0,1,1,1"/> + </tileset> + <layer name="background" width="20" height="15"> + <data encoding="csv"> +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 +</data> + </layer> + <layer name="overlay" width="20" height="15"> + <data encoding="csv"> +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 +</data> + </layer> + <layer name="overoverlay" width="20" height="15"> + <data encoding="csv"> +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,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 +</data> + </layer> +</map> 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") |