# Making the bricks permanently disappear in Brickbreaker

please format code with </> button * homework policy * asking questions

Hi! I am a beginner working on a Brickbreaker game, but I encountered some problems trying to make bricks permanently disappear when the ball hits it. Below is a method in my code that does it.

I expected a brick to disappear completely, but when I run, the bricks disappear for a split second when the ball hits it but is redrawn immediately after. Did I put any checkpoints in the wrong loops? Thanks!

``````void drawBricks() {
int [] bricksX = {30, 225, 410, 600, 800};
int [] bricksY = {30, 80, 130, 180};
boolean [][] isHit = new boolean [4][5];  //2-D array that I did not use
boolean [] hit = new boolean [20];  //array storing the collision status of each of the 20 bricks

for (i=0; i<4; i++) {   //row, y

for (j=0; j<5; j++) {   //column, x
fill(brickColor);
if (!(hit[i*5+j]) && ballX>bricksX[j]&&ballX<bricksX[j]+170 && ballY<bricksY[i]+40) {
Vy=Vy*-1;
hit[i*5+j]=true;
bricksX[j]=bricksX[j]+10000;      //move the x-value of the brick off-screen so it's not hit twice
}
if (!(hit[i*5+j])){      //if hit is false, draw the brick
rect(bricksX[j], bricksY[i], 170, 40);
}
}
}
}
``````

Hi! Welcome to the forum!

I think the problem is that all the variables are declared inside the function. They will be initialized every time you call the draw function. Instead, you want to move the array variables outside (i.e., declare globally) so the values hold during runtime.

And I donâ€™t know what the course is like, but you would eventually want to use class to keep variables as a set.