shooting effect

edited November 2013 in How To...

I am drew crosshairs and i want to make it that every time I click on the mouse it will "pop" an ellipse(it deletes the object that the crosshairs are over).

Answers

  • you need to give us more information, ideally the code you have so far.

    we won't write your assignment for you, not even for money*, but we can tell you what's wrong.

    (* this, unfortunately, isn't true)

  • edited November 2013

    here is what i have so far.

    int a = 5; //"a" value for Red balloon
    
    void setup() {
      size(500,500);
    }
    
    void draw() {
      background(255);
     //Red balloon
      fill(255,0,0); 
      ellipse(width/2,530+a,30,30);
      a= a-1;
    
     //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);
    }
    }
    
  • Answer ✓

    ellipse(width/2,530+a,30,30);

    i guess you haven't read the other thread then... about using a variable for x position of balloon.

    anyway, when you press the key you need to work out if the mouseX and mouseY are within the balloon and if it is then move the balloon back to the bottom. and increment the score, if you have one.

    you know the mouse position, you know the balloon position, you know how big the balloon is...

  • Answer ✓

    That's what I said in the other thread. Bad idea to ask the same question in different threads, it is just a loss of our time.

This discussion has been closed.