Blinking Minion (fixed)

Planning
Step 1
In this lesson, we will be drawing a minion using shapes

It will also blink when the mouse button is pressed.

Step 2
Draw the head and glasses

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 //

Check Your Work
Step 3
Save and run your code

We should see this:

Challenge
Step 4
Make the eye

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.

Check Your Work
Step 5
Save and run your code

You should see something like this:

Information
Step 6
The curve function

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:

Challenge
Step 7
Draw the smile

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.

Check Your Work
Step 8
Save and run your code

The minion should now have a smile.

Step 9
The mousePressed function

The mousePressed function is special because it will be automatically called when the mouse is pressed.

Add this code:

Challenge
Step 10
Make the minion blink when the mouse is pressed

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.

Step 11
The mouseReleased function

Similar to mousePressed, there is a special function called mouseReleased that is called when the mouse button is released.

Add this code:

Challenge
Step 12
Make the eye blink open 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.

Check Your Work
Step 13
Save and run your code

The minion should now blink shut and open when the mouse is pressed and released

The lesson is now complete!

Blinking Minion (fixed) Info

Account

MVCode Clubs

Created By

aaronjau101

Course:

Visual Effects lessons

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach