# Creative Coding with p5.js

> Students write JavaScript to model motion and forces, then build on those skills to simulate flocks, generate landscapes and prototype games.

[View programme page](https://tinkercademy.com/programmes/creative-coding-with-p5js/)

- Audiences: Students, Teachers
- Duration: Two levels, 30 hours each
- Domains: Computer Science Fundamentals
- Platforms: p5.js, JavaScript
- Updated: 2026-12-02

## Which level should my students start with?

Start with Level 1 if students are new to p5.js. Level 2 builds on Level 1: students should be able to organise a sketch using classes and use vectors to model motion. If they learned those skills elsewhere, tell us what they've built so we can suggest where to start.

## Course overview

What makes a ball bounce, a planet orbit or a flock turn together? Students use [p5.js](https://p5js.org/), a JavaScript library for drawing and animation in the browser, to turn those questions into interactive programs they can test. Drawing on Daniel Shiffman’s [_The Nature of Code_](https://natureofcode.com/), Level 1 teaches programming through physics. Level 2 uses those foundations to model groups, generate patterns and build games.

## Planning your course

**School levels:** Upper secondary  
**Format:** Two courses taught in sequence

Tell us what your students can already code, how long each lesson slot is and what devices they’ll use. If your school restricts browser-based tools or student accounts, let us know so we can discuss the setup.

## Learning outcomes

-   Write and debug JavaScript programs that handle input and manage many objects at once.
-   Turn a scientific idea into a working model and explain what the model leaves out.
-   Design rules for a simulation or game, then test how changing one rule affects the whole system.

## Curriculum and hands-on

### Level 1: JavaScript and physics modelling (30 hours)

Students start by drawing and animating in p5.js. They use loops and arrays to work with many objects, classes to give those objects their own behaviour, and vectors to describe motion. They compare random movement with the smoother variation of Perlin noise, for example by making a field of grass sway.

From there, they model acceleration and forces such as gravity, wind and drag. They might build a marble run or simulate planets that pull on one another. For a longer project, students can build an interactive physics visualisation that lets a classmate change a force and see how it affects the model.

### Level 2: Advanced simulations and game design (30 hours)

Students build on those motion models to program autonomous agents that steer, follow paths or flock. They use cellular automata to explore what happens when cells follow simple rules, from Conway’s Game of Life to falling sand and generated cave maps.

The follow-on can also cover recursive fractals, genetic algorithms and constraint-based generation: for example, using wave function collapse to assemble a map from tiles that must fit together. Other extensions include raycasting for line of sight, 3D scenes and networked multiplayer.

For a longer project, students might turn a board game into a playable video game with autonomous opponents or a map that changes each time.

## Enquiries

[Enquire for your school](https://tinkercademy.com/programmes/creative-coding-with-p5js/#enquire)
