I'm writing a shoot 'em up game on an Arduino and I'm using AABB collision detection -
ref: Bounding Box Collision Detection
My problem is with the time objects collide with each other, I'm currently using a basic trigger which is true for the duration two objects intersect. I think what I need is best described by the issue of pulse counting, where regardless of 'pulse length' (or intersection duration) only 1 count is detected:
How may I implement this in C++? the function I'm currently using:
bool CollisionTest( xPlayer, yPlayer, xAlien, yAlien, width, height)
{
if( ((xPlayer+width) >= xAlien) && (xPlayer <= (xAlien+width)) &&
((yPlayer+height) >= yAlien) && (yPlayer <= (yAlien+height)) )
return true;
else
return false;
}
You need an edge detector!
Not sure why you need to count them, but this should do it.