Collision Detection, gravity, and platforms? Oh my!

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.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Collision Detection, gravity, and platforms? Oh my!

Post by kikito »

It depends on the number of collidables involved, of course.

With just 2, it'll be blinding fast.

With 2000, it will probably be too slow, if you are comparing them with each other.

A possible optimization would be to use a quadtree. It's kind of tricky, but it severely reduces the amount of comparisons to be done.

I've done one quadtree in Lua, but I made some changes to it and haven't tested it yet - it's possible that it doesn't work. Uses middleclass and middleclass-extras.
When I write def I mean function.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Collision Detection, gravity, and platforms? Oh my!

Post by tentus »

Lua can do it (most machines probably without a hitch), but that has one hideous flaw: it only works for the player. I assume that at some point you will want enemies in the game? They'll need the same treatment, though you would be able to optimize them a bit by skipping over player only entries (coins, as an example). The same thing is true if you implement any kind of projectiles, like the mario fireballs.

I would be more efficient to take each actor (a moving creature or player) and check if anything is inside a certain radius, and then do proper collision detection.
Kurosuke needs beta testers
Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests