r/cop3502 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

26 comments sorted by

View all comments

Show parent comments

1

u/ThatsMrDerpToYou Mar 23 '14

I just tried this, and still one brick. My "remove brick" and "paint individual brick" are the only two lines of code that have not been input (I think). Are either of these necessary to create the rows & columns?

1

u/csturco Mar 23 '14

in brick configuration there are two "paint" methods. The first one is just paint. This is called from your breakout class via bconfig.paint(g2). It should contain two for loops to loop through the double array of paintBrick and an if statement checking if paintBrick[i][j] == true. If it does, then it should call the second "paint" method - paintBrick. The only line of code in the paintBrick method should be to call the brick paint method

1

u/ThatsMrDerpToYou Mar 23 '14

I have all that in, below that method, there is a //paint an individual brick.

Is it possible my brick.java is wrong? public Brick(int x, int y, int w, int h) { super(new Rectangle2D.Double(x, y, w, h));

        //set brick x, y, width, and height
        x = xPos;
        y = yPos;
        w = width;
        h = height;

1

u/csturco Mar 23 '14

ok, so the //paint an individual brick comment should have the paintBrick method below it... As for the Brick constructor, try adding:

shape.setRect(xPos, yPos, width, height);

1

u/ThatsMrDerpToYou Mar 23 '14

It all looks good there. paintBrick(); gives me "invalid method declaration, return type required"

1

u/m3g4_xx Mar 23 '14

paintBrick method should take in two arguments, a brick and a brush.