With the new project I’m working on, I’m trying to put more focus on maintainable code, and planning stuff out before implementation.
I’m currently working on a building system for my game, and before I work on building, I want to work on how I’m going to implement the system for tracking where tiles go. Essentially, I need a format to keep track of all tiles on a grid. However, because this isn’t a voxel game, you can place tiles on the sides, the top, or the center.
Essentially, like so (except you can also place stuff inside the box):
Essentially, every part on the image is where I want to be able to place tiles. My specific problem right now is implementation.
I can’t put six values per tile like so:
local tiles = {
//Number is tile ID
//This is pseudocode, I know these should be strings
{[left] = 0 [right] = 0 [back] = 1 [front] = 1 [top] = 0 [inside] = 10}
{[left] = 7 [right] = 2 [back] = 7 [front] = 1 [top] = 0 [inside] = 0}
{[left] = 0 [right] = 0 [back] = 1 [front] = 3 [top] = 4 [inside] = 9}
}
Because tiles share sides with others, this isn’t an option.
However, I’ve been thinking of using a strategy where each side has it’s own two dimensional dictionary, like so:
local leftSide = {
[1] = {
[1] = 0
}
}
Would something like the above work well? Any help is appreciated!