3 ms·
No, but like in every other programming language you can implement something like that yourself either by 1) nesting arrays (columns) within an array (rows) and
by zubspace 5y ago
No, but like in every other programming language you can implement something like that yourself either by 1) nesting arrays (columns) within an array (rows) and access items them by map[x][y] or by using a single array and transform x and y into an index like y*width+x.
I always take the second approach and wrap it in a class [1].
[1] https://github.com/ZuBsPaCe/godot-base-code/blob/main/Scripts/Tools/Map.gd https://github.com/ZuBsPaCe/godot-base-code/blob/main/Script...
- krapp 5y agoYou can also emulate a 2D array in 1D. For array[w][h] you would allocate array[w * h] and instead of indexing array[row][col] you would index array[w * row + col]. Wrap all of that in a nice API and for all intents and purposes it's the exact same thing. see https://stackoverflow.com/questions/2151084/map-a-2d-array-onto-a-1d-array https://stackoverflow.com/questions/2151084/map-a-2d-array-o...