Dave Drohan (SETU)

BACK NEXT

Mouse Example 3.5

In this step, we will implement an example from your lecture.

If the mouse is pressed:

     
     
 
     

Mouse Example 3.5

Create a new Processing sketch in your workspace and call it Example_3_5.

Enter the following code into your sketchbook (avoid the temptation to copy and paste it…you learn more by writing the code out):

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

void draw() {
   background(0);
   stroke(255);
   fill(128);
   if (mousePressed){
       rect(45,45,34,34); 
   }
   else{
       ellipse(45,45,34,34);     
   }
}