i am making a 2d snake game with a grid (ofcourse). and try to place the foodblock on a random row (y) and a random colunm(x).
i use this to find a random place:
private void EvaluateFoodPosition ()
{
foodPosition.row = random.Next (gridBehavior.rows);
foodPosition.column = random.Next (gridBehavior.columns);
}
but when i add walls, how can i say: place in random row and column except when the row and column are a wall. so the food dont spawn in a wall.
please help me
ps i am working in c#