I create a breakthrough game in C #, I use booleans to tell the program whether to draw a brick or not, I used the rectangle classes to overlay the drawn rectangles to find out if the ball has hit bricks
This is the code I've used so far:
Rectangle brick4 = new Rectangle((490), (50), (50), (20));
bool hitBrick4 = brick4.Contains(x, y);
if (hitBrick4)
{
brick4 = new Rectangle(0, 0, 0, 0);
brick4draw = false;
yChange = -yChange;
bricksdestroyed = bricksdestroyed + 1;
lblBricksDestroyed.Text = "Bricks Hit: " + bricksdestroyed;
}
I am trying to remove the rectangle class after the brick has been hit by setting it to zero, but the rectangle still exists and can still be hit by calling the brick code.
Any suggestions, sorry if I'm not very clear.
source
share