Efficient/fast collision detection system help.
I know how to do the simple kind of collision detection (making rectangles around my sprites and checking to see if they intersect), but now I'm working on a scrolling game (the kind with tiles). To have any kind of details, I need to generate a couple to generate a couple thousand tiles, but when I loop it, it tests every single tile to see if it collided with my camera entity, to check if it should be drawn. Checking a couple thousand tiles against a couple thousand tiles give me 0.001(my estimate) FPS.
The problem: Could anybody show me a small example of a more efficient way to check collisions, or maybe an idea to change my strategies?
Note: I googled it but every page I checked on collision detection told me to do it my way.
P.S. I didn't post any code, but if you need it, I can.
Re: Efficient/fast collision detection system help.
If you have a 2D tile system, I'm going to assume you have something like a 2D array. From there it should be pretty trivial to figure out which indices of the 2D array are on the screen. No real "detection" necessary.