# Hitboxes - Circles or Rectangles? Considerations...

This topic is 3034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey all. I'm making a Shmup game. I've been toiling with this and have considered going to circular hitboxes. It seems that the checks for those are faster, but at the same time it seems that I'll have to use floats, especially for them to be in the center of an object. It doesn't seem too complicated, but I just wanted to get things straight before doing this. The player is 28x32... Right now I'm just using a 2x2 hitbox, which would be located, within the sprite, starting at 0,0: 12,14 to 13,14. (Yeah, it's positioned a little ways up. Horizontally centered though. With a circle, I'd have to use 12.5 and 13.5 and then have a radius of 1? Another thought: Is it normal to use circles for these type of games due to the speed of checking? I recall reading that circles vs. circles are easy, but circles vs. other shapes are annoying... Advice appreciated, thanks.

##### Share on other sites
Circle vs Circle tests are very fast, but so are Axis Aligned Box vs Axis Aligned Box tests, and Circle vs AABB tests. It is normal to use the simplest collision shape you can get away with using, which depends entirely on the shape of your collideable object.

If, for instance, your player or bullets are pretty much circular, then using a circle for a collision shape is your best option. If they are a box (that never rotates), then an AABB would be a better option because it is a closer match for the underlying object. In other cases you may have to use a more collision shape, but I doubt you would need to for a Shmup.

But, is the only reason you are considering this change because of speed? If so have you profiled your code to make sure that your collision checks are your bottleneck? Theres no real point in optimizing (and in this case, I doubt it would be much of optimisation, if any) code that it not causing your game to run slowly. If however you want to switch so you can learn how to check for collisions between circles, then by all means, go right ahead [smile].

##### Share on other sites
Well, no. The speed isn't an issue... yet... heh. It seems the circles just may be more accurate is all. I just was worried it could make some things complex.

Right now it's just a core engine. I'm trying to figure out why the game runs faster when it has more to update rather than very little. o_O

##### Share on other sites
Quote:
 Original post by SivakI'm trying to figure out why the game runs faster when it has more to update rather than very little. o_O

What does your profiler say [wink]

-me

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631775
• Total Posts
3002284
×