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!
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;
}
}
}