It sounds like it is a vector reflect thing you need:
Vect1 is the direction of the ball before hitting the wall
Vect2 is after the wall
WallN is the normal of the wall
DOT is the dot product
Vect2 = Vect1 - 2 * WallN * (WallN DOT Vect1)
Here is the code in 2D ripped directly from my Phoenix Math Lib
[code=pascal]
// Vector reflection, V is the vector to reflect, N is the wall normal
Function VectorReflect(const V, N: TVector2f ): TVector2f;
var d: Single;
begin
d:= VectorDot(N, V);
Result.X:= V.X - 2 * N.X * d;
Result.Y:= V.Y - 2 * N.Y * d;
end;
[/code]
Bookmarks