Open jtara1 opened 8 years ago
This was an issue addressed by the professor when presenting the final project example. He acknowledged the issues existence but didn't seem to care about it too much. I doubt we need that level of error checking but later on we can implement this check. If it takes more than 400 tries to insert an element, we can iterate over the Grid to make sure that there are null elements. If there aren't any null elements, then throw an error.
In my personal / private implementation I kept an
ArrayList<ArrayList<Integer>>
containing empty tiles on the grid then got a random coordinate from this list & removed it everytime I created a newGameObject
for theGrid
.Right now we continually select a random column & row index then check if it's occupied and keep doing this until we find a spot of the Grid whose value == null
This could be an issue if almost all or all spots are filled up on the Grid.