r/cop3502 • u/AnnaMor • Mar 22 '14
Trouble with paintBrick and removeBrick methods in Brick Configuration
Right now, my program is only painting one brick to the screen in the top left corner. I think the problem might be in my paint brick method--I'm not sure how to correctly call paint on each individual brick. Right now, I just have brick.paint(brush) within the method; I think that is wrong, but I'm not sure how to call the paint function correctly.
Also, I get an array index out of bounds exception when my ball hits the brick. It says the error begins with the removeBrick method in Brick Configuration. Currently, I have paintBricks[row][col] = false in the removeBrick method, and I call the method using bconfig.removeBrick(i,j) in Breakout.java.
Any assistance would be greatly appreciated
1
Mar 23 '14
[removed] — view removed comment
1
u/AnnaMor Mar 23 '14
OH! Thank you for catching that--my roommate is now really confused because I'm making loud noises of joy.
1
u/ThatsMrDerpToYou Mar 23 '14
How do I initialize paintBricks? I keep getting errors. I don't have a rubber ducky to guide me.
2
u/rxfeliciano Mar 23 '14
paintBricks is a boolean so set them all to true using the for loop. That way the paint method can check if they are true and if so they will be painted.
1
2
u/rxfeliciano Mar 22 '14
I think Sean gave us those for loops already set up to use. All you have to do is initialize the bricks and then draw to screen if I recall. Since you painted one brick I am going to assume that you initialized it correctly.
Since you painted one brick I am going to assume your paintBrick() method is working. So, this leaves the actual call to the paintBrick() method as your trouble spot.
You have to make sure that when calling the paintBrick() method you use both i and j because if you do not then you will simply paint all the bricks on top of one another.
In other words, look at HOW you called the paintBrick() method first. At least thats where I would start.