I'm developing a 2D map editor for a game and I need a way to increase or decrease the size of the grid/map uniformly in all directions.
Suppose you have a 3x3 map with a sort of "cross" symbol.
(arrays are zero-indexed. They start with 0)
Like this:
0,1,0
1,1,1
0,1,0
The array would look like this:
map = [0,1,0,1,1,1,0,1,0]
So, tile index 4 would be the center of the map.
I'd like to increase the size from 3x3 to 5x5 for example. So I end up with this:
0,0,0,0,0
0,0,1,0,0
0,1,1,1,0
0,0,1,0,0
0,0,0,0,0
The new map array should end up like this:
map = [0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0]
What's a good way of doing this?