Mastodon Verification Link Orx Map Format: Part 1 – Sam Seltzer-Johnston

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. Sample

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.

  1. TileDefs is a mapping of identifier -> ConfigSection, where identifier is what’s later used in the Map keyvalue. The ConfigSection references a configuration section that can have a Graphic and/or a Physics Body.
  2. 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.
  3. MyCoolMapLayer is a child that inherits MapSectionBase and simply defines the tilemap layout. The intention is to create multiple layers.

The Map keyvalue has the following properties.

  1. Horizontal whitspace only acts as a delimiter. It is otherwise ignored.
  2. Line breaks increment the tile row and reset the tile column.
  3. Invalid tile identifiers will count as an empty tile. That is, they simply increment the tile column.
  4. 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.


Newer

Comments aren't enabled.
You're welcome to contact me though.