Sunday 16 March 2014

Tile "layers" for the Mapeditor

I'd been wondering about a problem for a while now, and didn't quite know how to solve it. Luckily Alycthul gave me an idea: layers.

What I've now done is modified the map format to allow for a tile to have an 'occupant'. An occupant is a tile that sits on top of another tile - forming a type of layer. For the sake of comparison here's a saved tile from both the old and the new formats:

Old
  x,y=id;
  0,0=1;

New
  x,y=id,occupant_id:tile_space_occupied;
  0,0=1,1301:1;

As you will know if you read my previous map editor posts the 0,0 represents a tile's coordinate and the 1 is the tile's ID. In the new format this is still here, but there's now a comma and then an additional value (1301 here). This is the occupant. The third value is the occupying space. I'm not entirely sure how to implement this yet, but it basically means how many tiles the occupant stretches over (in the case of a building or larger in-game unit). Currently this doesn't work and so all occupant sizes are treated as 1.

Tile occupants will typically be buildings, units or resources. This allows a unit or building to be placed as an occupant onto any sort of tile. Here's a screenshot of this in action:


As you can see here the crystals and train tracks are occupants of the other tiles. If you have any suggestions or questions feel free to leave a comment.

No comments:

Post a Comment