2D wireframe collision

Blitz3D Forums/Blitz3D Beginners Area/2D wireframe collision

andy_mc(Posted 2008) [#1]
In a game like asteroids, how do you handle collision detection when your objects are simple polygon shapes?


Stevie G(Posted 2008) [#2]
It really depend on how accurate you want them. Simple circle / circle intersections will work fine for most implementations of asteroids. If you want to be more complex you could use SAT ( separated axis theorem ).

Stevie


H. T. U.(Posted 2008) [#3]
There are countless ways to do collisions in a game like asteroids, from elipsoid-to-elipsoid collisions to linepicking along every edge.

A quick and accurate but unusual method is to "fill" the asteroid with invisible polygons (spheres would be best for Blitz collisions) and parent those to the asteroid. If any of those register a collision, then your asteroid has hit something. The size and number if the polygons would determine the speed and accuracy. For asteroid to asteroid collisions, the polygons would need to be slightly spaced so that they only collide with their own type when a asteroid collision takes place.

P.S. Stevie, I've never heard about SAT but am intrigued. could you explain it a bit?


Nathaniel(Posted 2008) [#4]
I think this is what Stevie is talking about:
http://en.wikipedia.org/wiki/Separating_axis_theorem
It looks much harder to implement than simple circle algorithms though.


H. T. U.(Posted 2008) [#5]
Achually easier than it looks (need to remember that) but doesn't work for concave polygons. In most cases though, circles would probrably be almost as accurate (since Blitz's has two radii to edit).