2D grid array question

Sorry for the misunderstanding.

This was an old post by me.

What I meant was that you could have one field that holds the player like in the game Snake. Now with cursor keys you could steer the player around. So you could store the player Pos as index of the grid like playerPosX and playerPosY and the cell class would have a field hasPlayer. Then you could move the player easily.

That would demonstrate the advantage of 2D grid over 1D array in that case. Because you just say +1, -1 to the 2 indexes, in a 1D list, that would be harder to do.

(The position of the grid cells remains the same, just the player wanders)

Sorry again, Chrisir

1 Like