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.
Collision Detection, gravity, and platforms? Oh my!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- 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!
When I write def I mean function.
- 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!
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.
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
Who is online
Users browsing this forum: No registered users and 40 guests