Collision Detection - how do they do it?

Ive played games like terraria, minecraft and worms world party, all great games, but how do they do their collision detection? I mean, trying to 'test' an entity or object against 10000 blocks in a loop is bound to be slow, so how do they get around that?

Do they use a compression algorithm, so it detect which blocks it will collide with?

I'm trying to develop a tile-based game myself, however this is one of the stumbling blocks I will come across.

All help is greatly appreciated, thanks!
It is actually surprisingly simple.

Use a big square for crude 'possible collision' detection.
Then use a few little squares for a more fitted collision detection.

Using a square (or circle) as an approximated edge to your objects is pretty easy, and looks like it works just right.

Hope this helps.
In a tile based game you can use the position and size of the object to calculate the tiles that the object overlap. If a tile is solid you have a collision.

To handle collision between objects you can let each tile store a list of objects located on that tile. So to check if an object collides with other objects you just do collision detection against all the objects in the lists of the tiles that the object overlap.

There are also other collision detection algorithms like sweep and prune that can be used and works also for non-tile based games.
Last edited on
Thanks for the replies, much appreciated. Just a curious question :)
Topic archived. No new replies allowed.