← Code

Drawing and animation with p5.js

Draw and animate with JavaScript and p5.js: shapes, movement, decisions, lists, objects and functions, ending in a small game you build yourself.

Start1. Shapes on a canvas

Shapes and movement

Draw on a canvas, make it move every frame, and make decisions.

1Shapes on a canvasNot started
2Making it moveNot started
3Deciding what to doNot started

Building blocks

Lists and loops, objects, and functions of your own.

4Lists and loopsNot started
5Objects and starsNot started
6Functions of your ownNot started

Final challenge: Catch the circle

Build a click-to-catch game with a score, lives and a restart. One optional lesson makes moving art.

7Final challenge: Catch the circleNot started

Click the falling circles to score. Fix a catch that works backwards, add lives and a game over, then add a power-up of your own.

  1. Predict
  2. Run
  3. Investigate › Which part does what?
  4. Investigate › When does the score go up?
  5. Investigate › Spot the bug
  6. Modify › Lives
  7. Modify › Play again
  8. A power-up
  9. Where this leads
Start lesson
8Moving art OptionalNot started

Use sin and cos to move things in circles, map to turn one range into another, and make a pattern of your own.

  1. Predict
  2. Run
  3. Investigate › What makes it turn?
  4. Investigate › Which piece does what?
  5. Modify › Trails
  6. Modify › A spiral
  7. Your own pattern
  8. Where this leads
Start lesson

Progress is saved in this browser only. Nothing is sent anywhere.

For teachers: Teacher guide (notes, answers, solutions, slides and worksheets)