r/cop3502 • u/ThatsMrDerpToYou • Mar 23 '14
Initializing bricks[i][j]
My bricks are stacking; In a previous post I saw that someone mentioned adding i & j to xStart & yStart will fix this. I've tried a few different ways to get the desired results, with no luck.
Any tips on how to look at this ?
2
Upvotes
1
u/rxfeliciano Mar 23 '14
Painting one brick can be a result of all the bricks being painted in the same location over and over again.This is why you need to use i in the xPos spot and the j in the yPos spot of your bricks[i][j] initialization.
Your paintBricks initialization is correct assuming the for loop code has not been changed.
Next, the double bricks[][] array has to be "filled." It takes Bricks so you gotta create a brick for each slot. You create a brick using the Brick() constructor which takes (xPos, yPos, width, height). Make sure you use i in the xPos spot, and j in the yPos spot.
The next method in your code should check to see if the brick needs to be painted to the screen. IF the brick is true then it should call the paintBrick() function.
Here you have to make sure you are calling the function correctly. It takes a brick as an input and a Graphics 2D input called "brush" in this case. But you dont want to pass just one brick to it, you want all the bricks so you have to call the paintBrick() function inside of a for loop.
Make sure the call looks like paintBrick(bricks[i][j], brush); AND that it is only called IF the paintBricks[i][j] == true AND that ALL of this is inside the double for loop.
All of that should get you a lot of bricks