# breakout clone problem (again)

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm really sorry to bring up the breakout collision problem again. I've had a look at the topics previously posted about the collision between the ball and the blocks and most of it just doesnt make any sense to me. i am new to programming so was wondering if someone could point me in the right direction. My math isnt that good so bare that in mind. I'm designing a 2D breakout clone and just want to know if theres any easy way to detect ball and brick collision. i have successfully managed collision with the bat and ball using sin and cos and putting the data into a array which i'm suprised i achieved but having no luck at all with the ball and brick collision, any help would be most appreciated, remember i'm a beginner....i'm using directx8...thanks

##### Share on other sites
well say if you have something like brickArray[25][20] (i picked 25x20 becasue 25 bricks can fit horizontaly and 20 bricks vertically if the bricks are 32x30 in a 800x600 resolution) now if you wanted to detect collisions with the bricks something like this should work ...

bool brickArray[25][20];// after you have filled it with where you want your bricksfor (int y = 0; y < 20; y ++){    for (int x = 0; x < 25; x ++)    {        if (brickArray[x][y])        {            xNew = x * 25;            yNew = y * 20;            // then you can use a standard bounding box            // check to see if they collided            // now say if they collided ...            brickArray[25][20] = false;        }     }}

so now if you draw them in the exact same way ... when you come to a brick that is false it wont be displayed.

hope this helped.

##### Share on other sites
Thanks but this wouldnt take into account the corners of the blocks and the ballspeed etc would it......

I was wondering if anyone knows some decent books on physics in games as i need to improve my knowledge in this area.

In the mean time anyone got anymore suggestions...

Thanks

##### Share on other sites
depends how square your blocks are and how fast your ball is going. is it going faster than a pixel per frame?

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 16
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632660
• Total Posts
3007693
• ### Who's Online (See full list)

There are no registered users currently online

×