• Advertisement
Sign in to follow this  

Collition Detection for irregular shape

This topic is 2299 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

Hi there, the question is when I want to paint a person stand or run on the irregular ground, how can I do the collision detection?
(The person and ground both are square graphics, and the ground is very big. )

Do you have any idea?

By the way, I use SDL as graphics engine.

Share this post


Link to post
Share on other sites
Advertisement
Normally, complex or irregular objects are composed of a combination of simpler, smaller objects. Here is a little example image, where each green capsule is a physical object used in the physics engine, all of which combined form the physical shape of the character used in the physics engine. It's in 3D, but the same concept still applies for 2D.

SDL is a good graphics library, but it won't do physics for you. If you want to do collision detection and physics, I recommend Box2D or Chipmunk Physics. And just a side note, it's "collision" not "collition".

Share this post


Link to post
Share on other sites
Appreciate for your help.

actually, i understand that irregular objects are composed of smaller objects, but how about the big and bumpy ground.

i want my character walk along the edges of ground smoothly. Should I cut the ground into pieces and wrap by collision box?

If yes, the code size may be very big, and I don't think so I can type the code by myself.


Normally, complex or irregular objects are composed of a combination of simpler, smaller objects. Here is a little example image, where each green capsule is a physical object used in the physics engine, all of which combined form the physical shape of the character used in the physics engine. It's in 3D, but the same concept still applies for 2D.

SDL is a good graphics library, but it won't do physics for you. If you want to do collision detection and physics, I recommend Box2D or Chipmunk Physics. And just a side note, it's "collision" not "collition".

Share this post


Link to post
Share on other sites
If you want the nitty gritty details then have a look here: http://realtimecollisiondetection.net/

The general idea is to break down your scene into a structure that you can search through very quickly. Then you want to find when and where objects collide in your scene. Once you know that, you can push them away from one another.

If your game is like "mario" where everything is a box then the problem becomes much easier to solve since you can search for potential collisions very quickly based on location of each of your blocks.

Share this post


Link to post
Share on other sites
Thanks a lot.

If you want the nitty gritty details then have a look here: http://realtimecollisiondetection.net/

The general idea is to break down your scene into a structure that you can search through very quickly. Then you want to find when and where objects collide in your scene. Once you know that, you can push them away from one another.

If your game is like "mario" where everything is a box then the problem becomes much easier to solve since you can search for potential collisions very quickly based on location of each of your blocks.

Share this post


Link to post
Share on other sites

Thanks a lot.
[quote name='marek-knows.com' timestamp='1320752690' post='4881734']
If you want the nitty gritty details then have a look here: http://realtimecollisiondetection.net/

The general idea is to break down your scene into a structure that you can search through very quickly. Then you want to find when and where objects collide in your scene. Once you know that, you can push them away from one another.

If your game is like "mario" where everything is a box then the problem becomes much easier to solve since you can search for potential collisions very quickly based on location of each of your blocks.

[/quote]
FYI, top posting isn't really encouraged on GameDev.net. It's not like it's a crime or anything, but the general style here is to bottom post. Just a friendly note.

Share this post


Link to post
Share on other sites

FYI, top posting isn't really encouraged on GameDev.net. It's not like it's a crime or anything, but the general style here is to bottom post. Just a friendly note.
[/quote]

Thanks.It make me to be a better man.

Share this post


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

  • Advertisement