Hello everyone,
I’m trying to make a game which makes the floor based on tile info which can be read from a text file, so that it passes that data into a multidimensional array (which then will be built as the actual level floor).
I’ve thought of two ways of doing this, both seem fine, but I don’t know which would be most CPU efficient:
First of all, my first idea was to store the floor data into a three dimension array (I’m using c sharp so that is already implemented), so then, the first two dimensions would be the x and y coordinates of the floor, and with the third dimension, I would be able to store data such as: height, which kind of tile is, moving cost to get to that tile…
so the 5,12,1 of my map array would hold for example, the value of the tile located at the square 6,13 (the arrays start counting at zero), and then the third dimension, would hold for example, another value telling a type of data from that tile, the height from above the ground for example.
I was writing all that down, to organize myself in which to start working first, when an idea came into mind: Instead of using a 3d array, i could just use a 2d array, and instead of holding integer values, it could hold another kind of variable made by myseld (which i could create in a new class) which could hold all of the properties on that square, so they could have different variable types. So now, i could call the [3,2].height, instead of the [3,2,1] value for that square.
Now that I look at it, i see the second method better, but I was wondering, would that increase the CPU cost of my script? (I care about that because I’m already planning on a path finding system in that kind of tile-based maps, so the whole thing might be a lot CPU consuming, I have to optimize things as much as I can).