
160 6. Collisions and Entities
sumRadiiSquared *= sumRadiiSquared; // Square it
// If corner and circle are colliding
if(distSquared.x + distSquared.y <= sumRadiiSquared)
{
// Set collision vector
collisionVector = *ent.getCenter() - corner;
return true;
}
return false;
}
Listing 6.10. e collideCornerCircle function is used when a circle is in the Voronoi region of
a box.
6.3 The Entity Class
e collision code we have been creating is part of the new Entity class. e Entity class
inherits from the Image class and adds the following:
• e ability to collide with other entities.
• Health property and related functions.
• Velocity and delta velocity ...