## Moving the eyes left-to-right with the mouse

#### Activity Description

This activity is optional, if you have the time give it a try. You will use some new concepts to have the eyes follow the mouse as it moves left-to-right.

#### Topics Covered

• if statements
• Using the min and max methods to calculate minimum and maximum values
• More practice with variables

#### New Concepts

• `min(a, b);`
is a function that returns the minimum of the two values a and b
• `max(a, b);`
is a function that returns the maxium of the two values a and b
• if statements are a construct in most programming languages, and they allow your program to make decisions, if the test is true a certain piece of code will execute
• `mouseX`
is a variable built into Processing that stores the x-position of the mouse

#### Instructions for moving the eyes with the mouse

• Create a new varaible (above setup) named eye_position and set it to the value of zero.
`float eye_position = 0;`
• Add the variable eye_position that you just created to the x position of your shapes that make up your eye(s). If I had
`ellipse(50, 50, 100, 200);`
as an eye, it would become
`ellipse(50+eye_position, 50, 100, 200);`
• Near the top of draw, below your volume statement create an if statement that asks if mouseX is greater than some value (the value will depend on your face, start with 220, and adjust as needed).
```if(mouseX > 220){

}```
• If the if statement is true, we want to move the eye(s) to the right, we will do this by using the min function (again you will need to adjust the numbers until it works for your face). Add the line of code below inside the curly braces of your if statement
`eye_position = min(eye_position + 0.5, 10);`
• Create a second if statement right below the first, that tests if mouseX is less than 180. Try this code out on your own, can you figure it out? It is very similar to the first if statements.

#### Code example for moving the eye to the right 