Skip to Content
Programming 2D Games
book

Programming 2D Games

by Charles Kelly
June 2012
Beginner
438 pages
15h 26m
English
A K Peters/CRC Press
Content preview from Programming 2D Games
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning 3D Game Programming

Beginning 3D Game Programming

Tom Miller

Publisher Resources

ISBN: 9781466508705