As shown in figure a classic table tennis game, I use the most commonly used to detect the ball with the racket collision formula is found when the ball quickly, table tennis is likely to miss out the racket, resulting in a penalty points, in order not to miss out the racket, I tried to use intersects, is to add an edge to the ball and the racket box, if the box crisscross, said the collision, but the code after the measured found miss racket ball will still exist, have a great god can give some ideas, here are the common collision detection code, can I now idea is rectangle racket into a rectangle, but don't know how to achieve
,,,
Private bool CollisionOccurred ()
{
//assume no collision
Bool retval=false;
//heading forward player one
If (m_ball. DX & lt; 0)
{
A Rectangle b=m_ball. The Rect;
A Rectangle p=m_paddle1. The Rect;
Retval=
B.L eft & lt; P.R d.light & amp; &
B.R d.light & gt; P.L eft & amp; &
B.T op & lt; P.B ottom & amp; &
B.B ottom & gt; P.T op;
}
//heading forward player two
The else//m_ball. DX & gt; 0
{
A Rectangle b=m_ball. The Rect;
A Rectangle p=m_paddle2. The Rect;
Retval=
B.L eft & lt; P.R d.light & amp; &
B.R d.light & gt; P.L eft & amp; &
B.T op & lt; P.B ottom & amp; &
B.B ottom & gt; P.T op;
}
Return retval;
.