1. ## Breakout algorithm help!!!

In a breakout game, the simplest way to determine if the ball hits the block is define the coordinates of the block, and when the ball is in the specific coordinate, the ball hits the block. The ball direction will be invert by positive/ negative 'speed'.
ex: if(hit==true)
speed *= -1;

But what if the ball is go straight into a corner of the block, what direction would the ball head to??? I've been dealing with this matter for like a week already and still haven't figure out. The speed of the ball also relative to the coordinate of the place where collision occur. The speed is faster, the colliding areas must be bigger.

when i want to determine if the ball only hit the left side of the block. I would create a bounding box around the left side of the block. Let just say "block.x" and "block.y" are the top-left of the block. "Ball.x" and "Ball.y" are the center of the ball, the ball has a radius of 10. Block's length is 30, width is 15.
Code:
```if( (Ball.x+10 >= block.x-1) && (Ball.x <= block.x-11))
{
if( (Ball.y+10 <= block.y+25) && (Ball.y-10 >= block.y))
return NormalLeft;
}```
The code works at certain point but it always goes wrong when it's near the corner.

So can anyone point out how can i fix this problem. By the way, i don't use the "invert speed" way to change the direction of the ball, but actually calculate the ball's angle with the blocks' normal.

2. What you actually need to do is create normals for each side of the block. The normals for your block (in DX) are:

Left -1.0,0.0,0.0
Top - 0.0,1.0,0.0
Right - 1.0,0.0,0.0
Bottom 0.0,-1.0,0.0

Do an AABB bounding box collision text between the ball and the brick. Find the interval of collision and if it is not empty then:

Multiply the ball velocity vector or direction vector by the normal of the surface of the block that the ball has hit.

If you don't want to do it this way you can use bounding boxes to encase sections of the bricks. Then test the sections and if the test passes (the ball has hit this area) then just switch the sign of the correct component of the ball vector.

Code:
```if (AABBCollide(Ball,LeftSideOfBlock))
{
Ball.Vector.x=-Ball.Vector.x;
}```