I assume X and Y are the ball velocity in the X and Y directions. Look at this snippet:
X = 80
Y = 80
X = 80
Y = 80
When the ball hits the brick, you just need to reflect it in the Y direction:
Y = Y
This way if it hits the top of a brick it will bounce up as well. This assumes that you can't bounce off the side of a brick though.
What you really need to do for breakout is to have an array of edges and normals. If the ball encounters an edge, it should be reflected about the normal. (A normal is the direction perpendicular to an edge.) Then you can either draw the bricks within the bounds of the edges or put controls there. You never have to draw the edges, they can be stored in memory. This apllies to bricks that aren't on a structured grid or may be oriented at an angle.
On a structured grid you don't have to compare the ball position to the position of all the bricks, or ANY of them for that matter. Given the position and direction of the ball it is easy to calculate what edge the ball hits next. If there is a corresponding block at that location you can bounce the ball, otherwise continue moving.
Lets say the grid elements are 10 units wide by 5 high. The velocity of the ball is (vx,vy) and its position is (x,y).
If vx > 0 then the next vertical gridline it encounters is (x mod 10) + 1, otherwise it's (x mod 10). It will strike that gridline in time=(gridlineX  x)/vx
Likewise for vy.
Now you store an array corresponding to the entire grid. Put a value in that array in all grid positions corresponding to a brick. That way you know whether to bounce the ball off a gridline or let it pass through.

__________________
To err is human; to debug, divine.
Last edited by darkforcesjedi; 04232008 at 08:05 AM.
