Jump to content
  • Advertisement
Sign in to follow this  
-justin-

collision boxes, per entity??!

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, this is probably like the third time i've asked a question related to this, but i just keep running into issues in the design department first a little overview of my game; as some of you may know (although have probably forgotten) i'm doing a game much like the arcade game x-men or the simpsons, where you have a character in a 2d-scrolling environment, and you move around and hit enemies; i've determined i'm going to use collision boxes, 1 for determining whether a player will be hit (their strike zone) and one for what they are attacking with (fists, sword, etc) i know i want to use quadtrees to help minimize my collision detection (since i plan on having a fair amount of projectiles) however, will i have to manually define 2 collision boxes for each sprite? so if a character has 5 sprites (2 for walking, 2 for punching, 1 for jumping) will i have to define 10 collision boxes?! i'm just needing some sort of guidance here... it seems like it would be hard to generalize since each character probably would have a slightly different height/width (or for some the difference might be immense) i'm quite unsure what to do; any feed-back would be much appreciated!!!

Share this post


Link to post
Share on other sites
Advertisement
You could always determine the bounding box programmaticaly by figuring out transparent pixels. This is actualy quite simple to do, all you have to know is the transparent pixel (this gets a little more complex, but is possiable for alpha transparent sprites aswell), once you have this you simply remove rows and top and bottom, and columns from the side untill a row/col has something other then a transparent pixel in it. As far as storing this information goes, record the offest (rows in, col in) and the size of the created box.

Share this post


Link to post
Share on other sites
hmm, interesting concept; however, i have NO idea how to do that in directx 9 (i'm still a n00b for graphics [it scares me] and so i generally use D3DX library)

if i'm to use that idea, can any1 shed some light on tutorials or the like to look for a transparent pixel/non transparent pixel?

Share this post


Link to post
Share on other sites
Using transparent pixels is certainly one way to do it. Basically, you are trying to find the outline of a character sprite by looking at the pixel data. You'll need to write a cute little algorithm that does this for you though.

The alternative is to manually define hitboxes/polygons per sprite frame. I would personally do this, even though it's more work. It can be fine-tuned in case you need it. But yes, you DO need to redefine the colission geometry on each frame. If you have a lot of frames, obviously that's a lot of work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!