Hiya:
I have tried to reproduce this equation to simple reflect a ball after colliding with a paddle (or screen bounds)
R = V – (2 * V[dot]N) N
I don't want to take the easy rout of just negating the velocity but is my first time trying to implement this equation (with little vector practice :( ) Perhaps I'm simply misunderstanding the formula.
Here's a little code snippet where I'm checking to see if the ball hits the right face of a paddle on the left side of the screen:
if(CheckCollision(bPos, b_Width, b_Height, p1Pos, p1_Width, p1_Height))
{
Vector norm;
norm.myVector.x = 1;
norm.myVector.y = 0;
float number = 0;
number = (2 * bPos.DotProduct(norm));
bPos.myVector.x = bPos.myVector.x - 2 * number * norm.myVector.x;
bPos.myVector.y = bPos.myVector.y - 2 * number * norm.myVector.y;
}
}