Introduction to Computational Media with p5.js

Unit 5 Functions

Overview

In this unit students go from drawing within the draw loop, to drawing within a function they create, to adding parameters to it and a return value.

Big Ideas

  • Understand how to abstract procedures for clarity and reuse

Enduring Understandings

  • Understand the purpose of functions
  • Understand how to extract repeating behaviors into functions with parameters

Goals

Functions
Understand how to create a function
Returning values
Understand how to create a function that returns a value

Learning Activities

Draw a happy face; draw two happy faces; write a happy-face-drawing function; draw many happy-faces.
Draw many happy-faces of different sizes
Create a function that returns a value

Final Project Prompt

Using functions, create a character that responds to user clicks and key presses by changing its expression

Level 1
Using functions, create a responsive character: when the user clicks, the character does something

Level 2
Add a different response that happens when the user presses a key

Level 3
Make a drawing stamp: when the user clicks, call your character-drawing function. Draw from two different types of character at random

Final Project Examples

Final Project Inspiration