// COMP1405/1005 - Day 08ish // example of mouseClicked() function // mjh-2013 // declare variables int count = 0; int x,y; // position for output // Initialize program void setup(){ size(600,400); background(222,222,0); fill(0); textSize(24); x = 25; y = height/2; } // define what the mouseCkicked() function does void mouseClicked(){ // when the mouse is clicked in a frame, // the code you add here will be executed. // this function is called either zero or one // time in each frame. (Never more than once.) count += 1; // Note: if you hold the mouse button down too // long, the "click" is sometimes not registered } // main body of program void draw(){ background(222,222,0); if (count == 0){ text("The mouse has not been clicked yet",x,y); }else if(count == 1){ text("The mouse has been clicked once",x,y); }else{ // mouse clicked 2 or more times text("The mouse has been clicked " + count + " times",x,y); } }