PDA

View Full Version : Collision Detection



VoS
January 23rd, 2010, 05:50 AM
Hey.

So Im just playing around a bit with flash as its been a while since I did so. Trying to create a small little space shooting game.

Im kind of wondering how you guys usually do collision detection between bullets and entities.

Currently all my game objects have a radius and i check every update if anything is colliding, if they are i deal with that.

Comming from java I am used to being able to thread out some sort of grid scheme so i dont have to check all vs all everytime, but rather only check collisions between objects in the same grid area.

Since I have quite a few objects constantly moving on screen I dont think that placing a gridscheme of some sort in the same loop would be a very good idea..

So im looking for how you guys usually solve collision detection when dealing with many entities.

For an example of what im doing, check here

http://xewly.com/z/sd/

The game is by no means finished, and lacks alot of pretty much everything.
Controls are via mouse (aiming)
and arrow keys to move.

For me it starts to lag to unplayable levels at around 100 seconds, at which point there are about 800 entities in the game.

So, are there any smart ways u guys solve these things?
Any premade quadtree libraries out there?

VoS
January 23rd, 2010, 07:08 AM
found this.
http://lab.polygonal.de/2007/09/09/quadtree-demonstration/
gonna see if i can find some example code, or if i just end up making my own system..

In the end I want there bo be so many enemies that one cannot see the background.

VoS
January 24th, 2010, 07:52 AM
Here was another example, this time with code
http://blog.sketchit.de/2009/12/quadtrees-actionscript-3/

dandylion13
January 24th, 2010, 11:48 AM
Hello :)

Grids are just fine if you're checking for collisions between more than about 100 objects. You'll definitely get a performance boost.

Less than 100 or objects, and I'm not sure if there would be a benefit to the extra overhead.