Hit Boxes refer to the spatial area with which an object can detect a collision or action. It’s a shape — often a rectangle — which the game’s programming uses to detect a collision, or hit. For example, the area in which Pac-Man can be hit by a ghost and cause the player to lose a life is the hit box. Also known as ‘bounding boxes’, ‘bounding volume’, or even ‘collision mask’, the hit boxes are essential to just about every collision detection system. Because of this, improper hit boxes can lead to some crazy bugs, including characters clipping through walls or an enemy hitting you even though visually they missed by a mile.
There are multiple approaches one can take to creating a hit box, varying by how detailed and accurate you want the hit box to be. A rectangular bounding box is the easiest. If the x-coordinate of the cursor is between the x-coordinates of the left and right sides of the bounding box, and the y-coordinate of the cursor is in between the y-coordinates of the top and botton of the bounding box, then you know the cursor is inside of the bounding box.
Some hit boxes can be calculated faster than others, resulting in better performance but often less accurate collisions. The previously mentioned simple rectangular bounding box is much easier to calculate than a 14-sided polygon … but if your character isn’t a rectangle, then there is bound to be an ‘empty’ spot which might register as a collision. It all depends on the performance and accuracy that you wish to obtain – you won’t be using a bounding box the size of an elephant for a tiny cardboard box. Sometimes you might WANT a simpler box, like the designers of one of the Street Fighter games did.
Popular hit box methods include bounding spheres, axis-aligned bounding boxes, bounding cylinders, oriented bounding boxes, k-discrete oriented polytopes, and convex hulls. (If that sounded like alphabet soup, check out the wikipedia article). You can also view some bounding volumes being used in this video.