Arrays for a heightmap tile-based map
- by JPiolho
I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation:
I've managed to store tiles and corners in memory but I'm having troubles to get borders structured.
For the tiles, I have a [Map Width * Map Height] sized array. For corners I have [(Map Width + 1) * (Map Height + 1)] sized array.
I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.
Tiles store the type (and other game logic variables) and via the array index I can get the X, Y. Via this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.
If someone even has a better way to store these for better memory and performance I would gladly accept that.
EDIT: Using in C# and Javascript.