Best practices on implementing collision detection?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
slmjkdbtl
Prole
Posts: 14
Joined: Sat Feb 25, 2017 8:36 am
Location: New York
Contact:

Best practices on implementing collision detection?

Post by slmjkdbtl »

Writing my own collision library, I found that both bump.lua and hc have "cells" in their implementations, what are cells for and how can cells improve efficiency or performance?

And are there any other best practices on implementing collisions?

Thanks!
嗡嗡嗡
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Best practices on implementing collision detection?

Post by zorg »

Spatial partitioning basically helps you in one meaningful way: You define smaller areas where you need to test for less objects colliding with each other, instead of testing for all existing objects colliding with all other existing objects.

There is, of course, a tradeoff still; if the "cells" are too large and few, or too small and numerous, it won't have the desired effect; what works for one game is something one needs to experiment out.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Best practices on implementing collision detection?

Post by ivan »

The only good reason for writing your own collision system is for simplicity's sake.
You could probably write your own collisions code for something like Flappy bird.
It doesn't make sense for more sophisticated games.
If you want features/performance, you might as well use box2d/love.physics.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests