It will also blink when the mouse button is pressed.
Add the following code:
Note: The green code is called comments. They are ignored by the computer and can be created by adding two slashes before any text //
We should see this:
You'll have to draw the rest of the eye on your own.
HINT: Use the "glasses frame" ellipse as a building block for making the other ellipses.
You should see something like this:
To draw a smile we will be using the curve function and the syntax looks like this:
curve(x1, y1, x2, y2, x3, y3, x4, y4)
Here's what each coordinate will need to look like for our smile curve:
Use the information in the step above and the hints below to make the minion smile.
HINT: Here is a diagram with the coordinates to some of the points for the curve. The question mark is coordinates that you need to figure out on your own.
The minion should now have a smile.
The mousePressed function is special because it will be automatically called when the mouse is pressed.
Add this code:
When the mouse is pressed, draw a big yellow circle to represent the eyelid.
HINT: That big white circle we made for the eye earlier can be used again with a yellow fill. You can also reuse the curve for the mouth and add a black fill.
Similar to mousePressed, there is a special function called mouseReleased that is called when the mouse button is released.
To redraw the eye when the mouse is released, it may be helpful to revisit Step 4 and Step 7 in this lesson.
The minion should now blink shut and open when the mouse is pressed and released
The lesson is now complete!
Visual Effects lessons
Created 11 days ago
Teach coding to your students with MVCode Teach
MVCode offers an integrated product designed to teach coding to students.
Learn more about MVCode Teach