# Help with my homework!

**URL:** <https://discourse.processing.org/t/help-with-my-homework/9211>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [March 12, 2019, 12:34am UTC](https://discourse.processing.org/t/help-with-my-homework/9211 "2019-03-12T00:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xlotg](https://avatars.discourse-cdn.com/v4/letter/x/e36b37/32.png) [@xlotg](https://discourse.processing.org/u/xlotg)\
**Post date:** [March 12, 2019, 12:34am UTC](https://discourse.processing.org/t/help-with-my-homework/9211/1 "2019-03-12T00:34:11Z")

</div>

I have to create a game where “balloons” float up the screen and when you click them they disappear. I’m having trouble making them disappear on mouse press and don’t know how to do this. Keep it simple please!

```auto
Balloon[] b = new Balloon[100];

void setup(){
  size(600,600);
  for(int i=0;i<b.length;i++){
    b[i]=new Balloon(random(width),random(600,1500),random(15,40));
  }
}

void draw(){
  background(#0981AF);
  for(int i=0;i<b.length;i++){
    b[i].drawBalloon();
    b[i].moveBalloon();
    b[i].wrapBalloon();
  }
}

class Balloon{
  float bX;
  float bY;
  float bD;
  float bS=random(0.5,2);
  
  Balloon(float tempX,float tempY,float tempD){
    bX=tempX;
    bY=tempY;
    bD=tempD;
  }
  void drawBalloon(){
    ellipse(bX,bY,bD,bD);
  }
  void moveBalloon(){
    bY=bY-bS;
    bX=bX+random(-1,1);
  }
  void wrapBalloon(){
    if(bY<-20){
      bY=900;
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [March 12, 2019, 1:56am UTC](https://discourse.processing.org/t/help-with-my-homework/9211/2 "2019-03-12T01:56:46Z")

</div>

pls format your code / by edit above post and use

```auto
</> code formatter

```

to paste your code.

* * *

yes, nice balloon code,  
is that the version they give you to add the mouseclick into?

-a- first need to detect  
mouse over balloon  
best is the distance between mouse pointer and balloon center  
[https://processing.org/reference/dist\_.html](https://processing.org/reference/dist_.html)  
could just change the stroke color for indication

-b- on click delete balloon?

- that is actually not easy for a array to delete a entry,
- more easy if use a arrayList type  
[https://processing.org/reference/ArrayList.html](https://processing.org/reference/ArrayList.html)  
( confusing but the functionality can see [https://processing.org/reference/StringList.html](https://processing.org/reference/StringList.html) )
- but there is a other trick:
- 
  - add a boolean variable to the class;  
boolean live = true;  
on click set it to false  
and instead delete from array make it invisible  
by change to background color / or NOT draw it.  
( just a idea )
