Game Development Reference
In-Depth Information
Using Tiled To Create Maps
While low level approach to drawing tiles in screen may be appropriate in some scenarios,
like randomly generated maps, we will explore another alternatives. One of them is this
great, open source, cross platform, generic tile map editor called
Tiled
.
It has some limitations, for instance, all tiles in tileset have to be of same proportions. On
Tiled
Tiled uses it's own custom, XML based
tmx
format for saving maps. It also allows
exporting maps to JSON, which is way more convenient, since parsing XML in Ruby is
usually done with
Nokogiri
, which is heavier and it's native extensions usually cause more
trouble than ones JSON parser uses. So, let's see how that JSON looks like:
02-warmup/tiled_map.json
1
{
"height"
:10
,
2
"layers"
:
[
3
{
4
"data"
:
[
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
0
,
0
,
65
,
6
\
5
5
,
65
,
65
,
65
,
65
,
65
,
65
,
0
,
0
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
0
,
0
,
0
,
65
,
65
\
6
,
65
,
65
,
65
,
65
,
65
,
0
,
0
,
0
,
0
,
65
,
65
,
65
,
65
,
65
,
65
,
0
,
0
,
0
,
0
,
65
,
65
,
65
\
7
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
\
8
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
,
65
\
9
],
10
"height"
:10
,
"name"
:
"Water"
,
11
"opacity"
:1
,
12
"type"
:
"tilelayer"
,
13
"visible"
:
true
,
14
"width"
:10
,
15
"x"
:0
,
16
"y"
:0
17