|
circle - circle collision |
chaseC
Member #8,368
February 2007
|
Hi, I am making an air hockey game and I need some help with puck to the thing you use to hit the puck collision. The collision isn't the real problem, the problem is that if I move the puck hitting thing to fast it goes through the puck and sends it in the wrong direction. I need some advise??? |
BAF
Member #2,981
December 2002
|
What, one account and thread wasn't enough to get people to program your game for you? |
Ceagon Xylas
Member #5,495
February 2005
|
Line collision. Begin the line at the puck, end it at the puck's coordinates plus it's velocity. Check to see if that line collides with any of the walls (other lines) |
chaseC
Member #8,368
February 2007
|
What I mean is that if the paddle (I don't know if it is actually called a paddle) moves to fast when it is in the path of the puck, it changes position so many pixels at a time that it moves into the puck and sends it in the wrong direction. Also I am not zavirx, my code doen't look anything like his ->
Also, I actually know how to add code tags;D |
Ceagon Xylas
Member #5,495
February 2005
|
My suggestion will solve this. Just replace the word 'walls' with 'paddles.' |
Andrei Ellman
Member #3,434
April 2003
|
Are the puck and the paddle both circular? The subject of the post is "circle - circle collision", but in the code you posted the puck has a width and a height which means it can be a rectangle. I'll assume you meant a circle-circle collision. A circle is the set of points that is at an exact distance (the radius) from the circle centre point. This means that any point who'se closest distance to the centre is is less than the radius is colliding with the circle. For two moving circles, you just need to find if the closest distance between the two line segments (each line segment is from the initial position of the puck to the position of the puck with the distance traveled during the iteration (velocity * length_of_iteration)) is less than the combined radii of the two circles. Don't forget to take into account that if the puck rebounds off a wall, the line-segment is broken. AE. -- |
zavirax
Member #8,634
May 2007
|
haha, ill be coming here when mines done because mines just square at the moment...finally, someone with a similar problem. And yeah your code is much more confusing and i guess advance than mine but mine kinda works so i dont mind because i know what im doing just dont know how to do it. |
|