Feb 19, 2017
Orx Map Format: Part 1
Most recent tinkering I’ve been up to is a format for defining maps for Orx that supports tiles and arbitrary object placement. This is my first progress update. First off, here’s a generated map with physics debug info.
Let’s look at the format I’ve devised so far:
[TileDefs]
aa = TileA
ab = TileB
ba = TileC
os = TileD
ee = TileE
ff = TileF
gg = TileG
12 = TileH
[MapSectionBase]
GridSize = 16
Tiles = TileDefs
[MyCoolMapLayer@MapSectionBase]
Map = "
ee ee ee aa
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
ab ba os ff gg
aa aa aa aa aa
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
aa aa aa aa aa aa aa
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
"
Here’s a breakdown of each section.
TileDefs
is a mapping ofidentifier -> ConfigSection
, whereidentifier
is what’s later used in theMap
keyvalue. TheConfigSection
references a configuration section that can have a Graphic and/or a Physics Body.MapSectionBase
is technically optional, but is a convenient configuration parent section that takes advantage of Orx’s config inheritance feature. I use it to define default map specs.MyCoolMapLayer
is a child that inheritsMapSectionBase
and simply defines the tilemap layout. The intention is to create multiple layers.
The Map
keyvalue has the following properties.
- Horizontal whitspace only acts as a delimiter. It is otherwise ignored.
- Line breaks increment the tile row and reset the tile column.
- Invalid tile identifiers will count as an empty tile. That is, they simply increment the tile column.
- Valid tile identifiers place a tile at the current row/column and increment the tile column.
And finally in code:
loadMapData("MyCoolMapLayer");
I’ll share the code for loadMapData
later. I still have a lot of features I’d like to add. It’s got a very naive implementation where each tile is represented by an object, which explains the low FPS. I plan to pack tiles so that they may be rendered using a shader, and bundle all physics bodies into one combined set of body parts.
Again, lots more to do, but this should give a basic idea of where I’m going with this. I hope to post another update soon.
You're welcome to contact me though.