So, this time I decided to take on something new: isometric maps.
Obviously I could go the easy way and use Tiled along with STi (which has an awesome implementation in Love), but I wanted to go down the hard route to see what I could learn along the way.
Finally, I present you guys with a pretty simple project where map information is stored on a simple JSON file. It currently supports ground textures and map props, such as trees or bushes or just about anything you draw and place on it.
The JSON structure is pretty straightforward:
Code: Select all
{
"textures":
[
{
"file": "myTexture.*",
"mnemonic": "myMnemonic"
}
],
"props":
[
{
"file": "myProp.*",
"mnemonic": "myProp",
"origin" : "50|72"
}
],
"data":
[
[["myMnemonic"],["myMnemonic"],["myMnemonic"]],
[["myMnemonic"],["myMnemonic", "myProp"],["myMnemonic"]],
[["myMnemonic"],["myMnemonic"],["myMnemonic"]]
],
"general":
[
{
"name":"Map name",
"version":"string with map version",
"lighting":"255|255|255"
}
]
}
Code: Select all
Textures =-=-=
file --> The texture file to be used. Can be any image file love supports.
mnemonic --> How they'll be referred to in the data matrix. See below.
Props =-=-=
file --> Texture to be used by the prop. Can be any image file love supports.
mnemonic --> How the prop will be referred to in the data matrix. See below.
origin --> The offset for drawing the picture, so it gets drawn correctly. X and Y values separated by a pipe ("|").
Data =-=-=
The actual map data. It's a 2D matrix written with the mnemonics mentioned above. If you saw the example JSON above, you
probably already understood how this works.
General=-=-=
name --> a string with the map name.
version --> a string with the map version
lighting --> R|G|B values separated by a pipe. Used to simulate day/night color "pallete".
The code can be found on github aswell.
Attached below is a simple demo. It did perform well on my pretty old machine, but tell me if you have any problems.
Ignore the weird tree. I suck at drawing.
I could maybe make a library out of this, but it currently uses some hardcoded paths (specifically for loading textures). I'd also need to cleanup a bit of the messy code.