Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

izhbq412

Collision

This topic is 5449 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 all, I''ve got a problem making a simple 2D game and I need some help. What I want to do is to have a circle colliding with a polygon. I''ve already found a way to calculate if the circle is colliding with either side of the polygon so now I only need a way to make the ball collide correctly. Its velocity is stored as 2 floats xv and yv. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
You know... the ball comes with certain velocity and a certain angle towards a side of a polygon which is for example with endpoints x1=10 y1=20 and x2=50 y2=5. And the ball reaches the side with velocity, say, xv=-5 yv=3. How should xv and yv change?

Share this post


Link to post
Share on other sites
OK but... ah... how am I supposed to post it? I mean I need to upload it on a free server first, right? I know a lot of free servers but none of them is visible outside BG (of course)

Share this post


Link to post
Share on other sites
quote:
Original post by ACAC
Can you draw a diagram of your problem? Its easier to understand then .


Do you mean something like this?

Y
6|
5|
4|
3|
2|
1|------*-----*>
0|_ _ _ _ _ _ _
0 1 2 3 4 5 6X

each * represents 1 frame.. so that would be the speed of 0yv and 3xv (only it starts at 1,0 in the coordinate system)

Edit: it doesn't look the same after i posted it :/ .. well, u get the picture :>

[edited by - RefikuL on August 18, 2003 6:19:26 AM]

Share this post


Link to post
Share on other sites
yes, that's how it is

PS: only that (0,0) is the upper-left corner, of course

[edited by - izhbq412 on August 18, 2003 6:25:51 AM]

Share this post


Link to post
Share on other sites
I think it would just change to xv5(when it bounces off the left wall) instead of -5 and keep the y3 value until it hits the "roof", and then change y3 to y-3.. too bad i lack at programming skills to test this myself :D

Edit: it only works on 90° walls tho.. :o otherwise u probable need to figure out the angle and make advanced calculation

[edited by - RefikuL on August 18, 2003 6:28:03 AM]

Share this post


Link to post
Share on other sites
You mean xv = -xv or yv = -yv? That works only with rectangles.

[edited by - izhbq412 on August 18, 2003 6:31:07 AM]

Share this post


Link to post
Share on other sites
Well then I dont think I can help any more. Maybe you should post this in mathematchics forum.. btw I think I saw a post on something similar yesterday..

Share this post


Link to post
Share on other sites

  • 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!