• ### What is your GameDev Story?

Public Group

#### Archived

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

# Collision

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

## 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 on other sites
In what way "collide correctly"?

##### Share on other sites
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 on other sites
Can you draw a diagram of your problem? Its easier to understand then .

##### 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 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 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 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 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 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..

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 29
• 16
• 11
• 10
• 11
• ### Forum Statistics

• Total Topics
634112
• Total Posts
3015584
×