Computer Science Canada Help With Breakout Killin Bricks |
Author: | Ryft [ Sun Jun 05, 2005 10:11 pm ] | ||
Post subject: | Help With Breakout Killin Bricks | ||
Well after playin around with my programming alil bit and creating bricks based on 2-D arrays. I've run into another problem. Whenever my ball hits a brick it destroys every block up and to the right of the brick which the ball hit. I think I know whats casusing it, but dont know how to fix it.
This draws the bricks and bases the colors (bricks (xBrick,yBrick)) as the color grey. Once the ball jits one of the bricks it is supposed to turn only that one green, but for sum reason it turns all the ones up and to the right green. Any help would be appreciated. |
Author: | jamonathin [ Mon Jun 06, 2005 7:58 am ] | ||||||
Post subject: | |||||||
Here's your problem.
Now in this if statement.
You tell the current brick color to be green, but you're still running through the for loop. What you should do is just add an 'exit' to the end of the if statement so that it exits that for loop. (Just so you dont mess it up)
You should also exit the other for loop at this time as well. You can asign a variable to determine when to exit the first for loop, which would probabily be easiest. Next time just send your whole code so we can help you with anything else you may not know about, and also so we can test if our methods are correct. EDIT: You should have where you draw your boxes seperate from your collision detection. |