i have an array that stores indexes of cells in a 4X4 grid, 0, 1, 2, 3, etc. I know that directly next to item 0 is item 1 (to the right) and item 4 (below). How would i write a function that returns indexes of cells that are directly next to the index passed in?
function getCellsAround(0)
{
should return 1 and 4
}
Something like that? That uses x, y coordinates (Point class) rather than just:
(1, 2, 3
4, 5, 6)