# Some please help me with my code

**URL:** <https://discourse.processing.org/t/some-please-help-me-with-my-code/29254>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 9, 2021, 9:20pm UTC](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254 "2021-04-09T21:20:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryce](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@Bryce](https://discourse.processing.org/u/Bryce)\
**Post date:** [April 9, 2021, 9:20pm UTC](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254/1 "2021-04-09T21:20:05Z")

</div>

Hi, my name is Bryce,

```
 I am confused about how to make the squares disappear once to circle hits them. Here is my code

```

// circX is for the smaller circle  
let circX;  
// circY is for the smaller circle  
let circY;  
//bulletX is for the shooting bullet  
let bulletX;  
//bulletX is for the shooting bullet  
let bulletY;  
// is for the first blue rect  
let rect1x=0;  
let rect1y=0;  
// is for the second green rect  
let rect2xx=40;  
let rect2yy=0;  
// is for the third red rect  
let rect3xxx=80;  
let rect3yyy=0;  
// is for the fourth pink rect  
let rect4xxxx=120;  
let rect4yyyy=0;  
// is for the fifth blue rect  
let rect5xxxxx=160;  
let rect5yyyyy=0;  
// is for the sixth green rect  
let rect6xxxxxx=200;  
let rect6yyyyyy=0;  
// is for the seventh red rect  
let rect7xxxxxxx=240;  
let rect7yyyyyyy=0;  
// is for the eighth pink rect  
let rect8xxxxxxxx=280;  
let rect8yyyyyyyy=0;  
// is for the ninth blue rect  
let rect9xxxxxxxxx=320;  
let rect9yyyyyyyyy=0;  
// is for the tenth green rect  
let rect10xxxxxxxxxx=360;  
let rect10yyyyyyyyyy=0;

// is for the mouseX to lead the object  
let myMouseX;  
// is for the mouseY to lead the object  
let myMouseY;  
// to enable shooting  
let shoot = false;

function setup() {  
createCanvas(400, 400);  
}

function draw() {  
background(“turquoise”);  
// for the bullet to follow the mouse  
bulletx = mouseX;

// to activate the bullet  
circle(bulletx, mouseY, 10);

if (bulletx \>= rect1x){  
rect1x = 5;  
}

//middle line  
rect (0,250,400,0);

// rect1  
stroke (“Black”);  
fill (“Blue”);  
rect (rect1x,rect1y,40,40);  
// rect2  
stroke (“Black”);  
fill (“green”);  
rect (rect2xx,rect2yy,40,40);  
// rect3  
stroke (“Black”);  
fill (“red”);  
rect (rect3xxx,rect3yyy,40,40);  
// rect4  
stroke (“Black”);  
fill (“pink”);  
rect (rect4xxxx,rect4yyyy,40,40);  
// rect5  
stroke (“Black”);  
fill (“Blue”);  
rect (rect5xxxxx,rect5yyyyy,40,40);  
// rect6  
stroke (“Black”);  
fill (“green”);  
rect (rect6xxxxxx,rect6yyyyyy,40,40);  
// rect7  
stroke (“Black”);  
fill (“red”);  
rect (rect7xxxxxxx,rect7yyyyyyy,40,40);  
// rect8  
stroke (“black”);  
fill (“pink”);  
rect (rect8xxxxxxxx,rect8yyyyyyyy,40,40);  
// rect9  
stroke (“Black”);  
fill (“Blue”);  
rect (rect9xxxxxxxxx,rect9yyyyyyyyy,40,40);  
// rect10  
stroke (“Black”);  
fill (“green”);  
rect (rect10xxxxxxxxxx,rect10yyyyyyyyyy,40,40);

circX = mouseX;  
circY = mouseY;

// all is for the boundries for the purple circle  
if (circY \<= 275){  
circY = 275;  
}  
if (circX \<= 25){  
circX = 25;  
}  
if (circY \>= 375){  
circY = 375;  
}  
if (circX \>= 375){  
circX = 375;  
}

// big circle  
stroke(“Yellow”);  
fill (“Purple”);  
circle(circX, circY,50);

if (mouseIsPressed){  
if (mouseButton === LEFT){  
shoot = true;  
myMouseX = mouseX;  
myMouseY = mouseY;  
}  
}  
// to enable shooting  
if (shoot == true){  
myMouseY = myMouseY - 5;

```
// smaller circle
stroke("yellow");
fill("red");
circle(myMouseX,myMouseY,10);

```

}

}

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [April 9, 2021, 9:32pm UTC](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254/2 "2021-04-09T21:32:46Z")

</div>

Please don’t open new threads for the same topic: [Help with my code](https://discourse.processing.org/t/help-with-my-code/29013/1)

---

<div class="post-metadata">

**Author:** ![Bryce](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@Bryce](https://discourse.processing.org/u/Bryce)\
**Post date:** [April 9, 2021, 9:39pm UTC](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254/3 "2021-04-09T21:39:46Z")

</div>

sorry i just don’t get it do you have any help

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 10, 2021, 2:32am UTC](https://discourse.processing.org/t/some-please-help-me-with-my-code/29254/4 "2021-04-10T02:32:31Z")

</div>

You need to detect when a circle hits a square.

> **[Collision Detection](http://www.jeffreythompson.org/collision-detection/circle-rect.php)**
>
> An online book about collision detection using Processing.

When this occurs, you know you need to stop drawing that square. This means you will somehow need to track if a square is still being shown or not.

In the example I gave you before, that is accomplished by a `is_visible` variable in the `Box` class. If you look at it in detail, you can see that a Box is only drawn when its `is_visible` variable is true.
