respawn a circle?

edited December 2013 in Using Processing

Hello, I am having difficulties making the red circle appear after it has left the screen, it stars at a random point on the x atis and below the y axis then it goes up.

    int a = 5; //"a" value for Red balloon
    float x = random(100,400);


    void setup() {
      size(500,500);
    }

    void draw() {
      background(255);

     //Red balloon
      fill(255,0,0); 
      ellipse(x,530+a,30,30);
      a= a-2;


     //crosshair
      line(mouseX, mouseY-7, mouseX, mouseY-24); //vertical bar
      line(mouseX-12,mouseY-12,mouseX,mouseY-12); //left bar
      line(mouseX+12,mouseY-12,mouseX,mouseY-12); //right bar

    //bullet
    if (mousePressed) { //black dot on crosshairs
      fill(0);
      ellipse(mouseX+.49998,mouseY-12,5,5);
    }
    if (a<0){
      a=a;
    }
    }//end of draw

Also how would I make it that when the crosshair is over the ballon and the mouse is pressed the ballon will be deleted, but then another balloon is spawned eventually? P.S the crosshair's have been adjusted to be 12 units above the y axis, while still on the same x axis. I believe I have to use boolean to make this happen, but I do not have much experience with boolean.

Answers

Sign In or Register to comment.