How do I find tiles intersected by a bounding box?

Jun 16, 2013 at 3:39 PM
How would I detect the tiles that a bounding box intersects properly? Obviously I could loop through every tile and check the display rectangle for overlap but there must be a better way.
Coordinator
Jun 16, 2013 at 7:23 PM
There is. If you take your top-left and bottom-right bounding box coordinates and divide them by the tile width and height (taking the integer part), you will get an extent of tiles (top-left, bottom-right tile coordinates) that you can check against the bounding box.
Jun 16, 2013 at 9:21 PM
Thanks for the help! I've been implementing a collision model with some guidance from here, and this helps a lot.