Project Update: Collision Detection – I really am stupid…

Well the narrow phase works now, a really useful tip: when iterating through an array in a for loop don’t forget to put the counter variable in the square brackets (anyone know what that’s called? – I’ve gone blank)


for (int i =0 ; i < array.length() ; i++)


for (int i =0 ; i < array.length() ; i++)

Sometimes I wonder why I don’t fall over more often.

Anyway I’ll work on cleaning it up and post it here soon.


Project Update: Collision Detection

No I’m not dead, sorry to disappoint.  I’ve been working on collision detection and am not getting too far with it right now.

I am using a simple but flexible design, each entity has an outer bounding box – a rectangle – that is used for an initial broad phase, then one or more convex polygons that are tested for the narrow phase.  This allows for a quick removal of un-necessary checks and some added flexibility in the narrow phase, for example in a space shooter getting hit in the cockpit could cause death whilst a hit to the engine could cause speed loss or manoeuvrability issues.

In the image above the green box represents the outer bounding box and would be used for the broad phase, the three blue polygons would be used in the narrow phase to determine which area had been hit.

Initially this started quite well, the broad phase is easy and works nicely, the narrow phase is not going quite so well.  I’m currently failing to implement a routine based on the separating axis theorem because – and I’m pretty sure this is the reason – I’m a moron.

Maybe I’ll look at tidying up the scene manager instead…