2D grid array question

You have only one grid and you overwrite it.

To achieve this you could name the 2nd grid grid2.

BUT having 2 grids doesn’t have to do with 2D grid. In fact before you work with 2 2D grids you should first appreciate working with ONE 2D grid. It would exactly look the same as your 1D grid from your last sketch but the data are ordered now in a way that is also like a grid internally (grid instead of list).

The advantage of a 2D grid is for example that you can find the neighbor cells of a cell much easier. Just add 1 or -1 to cell index x and y. [x+1][y]

Try this in a new sketch with only one 2D array and move a selected cell over the grid with cursor keys. (seleted cell wanders over the grid). Or make it so that when you click on a cell all 9 neighboring cells get selected. That’s easier in 2D array although it looks the same on the screen as your 1D array from the previous sketch.