I have this "Breakeout style" game.
I have a cannon at the center, blocks around the cannon and pads around the blocks. This is how the game looks like:
I've managed to get the collision per pixel and my ball "reflects" on contact with the blocks with the following math:
Ball.Direction = 2 * (Block.Direction - Ball.Direction) + 180;
Where the blue line is the ball direction, and the black line (base line) is the block surface.
Direction is a angle expressed in radian (that can be convert to degrees, of course).
The ball is moved by:
// Event.ENTER_FRAME
x += Math.sin(Direction) * Velocity;
y -= Math.cos(Direction) * Velocity;
So far, so good.
My problem comes now, with the pads (the 3 dark and large blocks around the small colored blocks).
As they turn around, the surface angle changes.
More than that, the ball should hit the sides too, so, how can I measure the direction of the hit and the new direction of movement of the ball?
ps: If needed, I can supply code and a playable swf.
Edit
Ok, the problem with angles was solved with Vectors, but I still have the problem with sides and back collision.
I'll open another question for that and link it here.