# Help with my code

**URL:** <https://discourse.processing.org/t/help-with-my-code/29013>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [March 31, 2021, 2:03pm UTC](https://discourse.processing.org/t/help-with-my-code/29013 "2021-03-31T14:03:35Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [March 31, 2021, 2:03pm UTC](https://discourse.processing.org/t/help-with-my-code/29013/1 "2021-03-31T14:03:35Z")

</div>

Hello, my name is Bryce,

```
   I have been working on a project for a while and I just cant get it. This is what I'm supposed to do: 

```

“Your job is to create a game where there is a row of boxes along the top of the canvas, and a mid-line that your player cannot cross (the program will stop it). Your player should also be contained to the boundaries of the canvas. Your player should then be able to shoot at the squares and when the square are “hit” they should appear to disappear”.

I have completed everything except for making the squares disappear upon contact with the bullet anything helps.

and this 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;  
// is for the second green rect  
let rect2x=40;  
// is for the third red rect  
let rect3x=80;  
// is for the fourth pink rect  
let rect4x=120;  
// is for the fifth blue rect  
let rect5x=160;  
// is for the sixth green rect  
let rect6x=200;  
// is for the seventh red rect  
let rect7x=240;  
// is for the eighth pink rect  
let rect8x=280;  
// is for the ninth blue rect  
let rect9x=320;  
// is for the tenth green rect  
let rect10x=360;

// 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 (0,0,40,40);  
// rect2  
stroke (“Black”);  
fill (“green”);  
rect (40,0,40,40);  
// rect3  
stroke (“Black”);  
fill (“red”);  
rect (80,0,40,40);  
// rect4  
stroke (“Black”);  
fill (“pink”);  
rect (120,0,40,40);  
// rect5  
stroke (“Black”);  
fill (“Blue”);  
rect (160,0,40,40);  
// rect6  
stroke (“Black”);  
fill (“green”);  
rect (200,0,40,40);  
// rect7  
stroke (“Black”);  
fill (“red”);  
rect (240,0,40,40);  
// rect8  
stroke (“black”);  
fill (“pink”);  
rect (280,0,40,40);  
// rect9  
stroke (“Black”);  
fill (“Blue”);  
rect (320,0,40,40);  
// rect10  
stroke (“Black”);  
fill (“green”);  
rect (360,0,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);

```

}

}

---

_[View the full topic](https://discourse.processing.org/t/help-with-my-code/29013)._
