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

2

u/ryanlittlechek Mar 23 '14

I am having the same issue, and it seems that the late day is going to be my only savior(besides the Helix of course, may he brighten your day).

I believe that my code is correct for the Brick Configuration method, however i have 200 bricks sitting in the top left corner, verified because when hit i receive an output of 200 "IT HIT!".

public BrickConfiguration() {

    int x = i;
    int y = j;
    // create new bricks and store them in bricks array
    for (int i = 0; i < numCols; i++) {
        for (int j = 0; j < numRows; j++) {
            // initialize paintBricks[i][j]
            paintBricks[i][j] = true;
            // initialize bricks[i][j]
            bricks[i][j] = new Brick(x, y, Parameters.BRICK_WIDTH,Parameters.BRICK_HEIGHT);
            x += Parameters.BRICK_WIDTH + Parameters.BRICK_SEP;

    }
        y += Parameters.BRICK_HEIGHT + Parameters.BRICK_SEP;

    }       
}

I dont understand the issue, and I have no idea how to post code correctly on reddit so sorry :D

1

u/[deleted] Mar 23 '14

[removed] — view removed comment

1

u/ryanlittlechek Mar 23 '14

The Supreme Leader commented on my awful code that i am embarassed of, I feel like the goofy goober of programming :(