Real-Time in an unreal world...

Started by
1 comment, last by origil 18 years, 4 months ago
This is an issue that had me shaking up 4 different search engines including myself for about 2 weeks now... I just don't get it. I'm trying to get quality collision detection in a breakout game but still... I know how to predict a collision between 2 circles and how to tell if there's a collision between a circle and a line. But I can't get to predict a collision between a circle and a line... Thinking it out again, maybe the game wouldn't need to predict collision in such fashion because if I'm using time delta movement and I manage to keep my game at 50 fps [at minimum] then in order for an object to skip collision it'll have to be moving at more than 50 pixels per second and that'd still be far from missing collisions. Is this approach correct? Should I consider medical help? Is there an answer to this question that might bring a smile to my face or is it going to fund my future psychologist's bank account? Thanks in advance, Ori
The Department of Next Life - Get your Next-Life Insurance here!
Advertisement
Collision of moving circle with line is simple. You need to find when distance between circle center and line get smaller than radius of circle. This is the same as finding when circle center enters the area around line where points is closer to line than r.

To get idea, draw line on paper, and draw circles around end points of line, and connect circles tangentially so you get kinda capsule-like shape. All points outside of this shape is further away from line than radius, and all points inside are closer.
The circle is colliding with line when circle's center enters the "capsule". So to predict collision of circle with line you need to intersect circle center's path with "capsule". To do that you only need to compute line-circle intersection for rounded ends of "capsule" and line-line intersection for sides of "capsule".

(as about practical, i think in the game such as breakout you can aswell do several intersection checks per frame (and make it run at 50 fps atleast) so it'll be accurate even for really fast ball. But then it is probably more interesting to do collisions right...)
Thanks!
I'll use that.
The Department of Next Life - Get your Next-Life Insurance here!

This topic is closed to new replies.

Advertisement