2D Gaming - How to deflect the ball off the bat?
I am new to XNA and game developer and am stuck with ball reflection. My ball reflects when it hits the bat, but only at one angle, no matter what angle the bat is at.
Here's the code:
if (BallRect.Intersects(BatRect))
{
Vector2 NormBallVelocity = Ball.velocity;
NormBallVelocity.Normalize();
NormBallVelocity = Vector2.Reflect(Ball.velocity, NormBallVelocity);
Ball.velocity = NormBallVelocity;
}
The ball moves back. How do I make the ball bounce off the bat?
I've seen other posts, but they are on the 3D front. I am too new to translate it into 2D terms ...
+2
a source to share
3 answers
Referring to the MSDN Reflection Method , it looks like you want to reflect the speed and rate of a bat.
+1
a source to share