Source: https://mokxi.com/teachers/plans/physics-engine
Updated: 2026-11-19

Lesson plan

# Write a physics engine lesson plan

Build a 2D physics engine in C++ on an ESP32-C3: vectors, time steps, integration, collisions, springs, friction and rigid bodies, ending in a tilt-driven marble sandbox.

4 chapters, 7 lessons, about 6 hours, on the ESP32-C3-DevKitM-1. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Vectors, fixed time steps, and why the order of two lines keeps a moon in orbit.
- Impulses that keep momentum, and the force law behind every rope and shock absorber.
- Stick and slip on a rolling deck, then bodies that turn as well as move.
- An MPU6050 tips a tray of marbles: the whole engine in one loop.

### Materials for the whole unit

- Accelerometer and gyroscope, MPU6050
- ESP32-C3-DevKitM-1
- Full-size breadboard
- TFT display, 240x320

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 40 min

## Motion

Vectors, fixed time steps, and why the order of two lines keeps a moon in orbit.

Lesson | Time | What students do

Vectors and time steps Write a 2D vector type with real C++ operators, move a probe through space one fixed time step at a time, and keep physics on its own clock. | 45 min

- A vector type
- One step at a time
- Physics keeps its own clock
- Bigger steps

Integration Drop a ball and put two moons in orbit, and watch the order of two lines decide between a stable orbit and a moon spiraling off into space. | 55 min

- Drop a ball
- Two moons
- Count the energy
- Watch them go
- Smaller steps

### Materials

- ESP32-C3-DevKitM-1
- Full-size breadboard
- TFT display, 240x320

### Check for understanding

Each student finishes "Integration" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Smaller steps".

Chapter 2. About 1 h 40 min

## Hits and springs

Impulses that keep momentum, and the force law behind every rope and shock absorber.

Lesson | Time | What students do

Collisions Detect overlapping asteroids, push them apart, and bounce them with an impulse that keeps momentum exactly, and energy as much as restitution allows. | 45 min

- A head-on hit
- Conserved
- An asteroid field
- Make them thud

Springs Hooke's law and a damper: measure a spring's period against theory, find critical damping, and hang a swinging tether of eight masses from a station. | 55 min

- Measure the period
- Add a damper
- A tether
- A heavier mass
- Critical damping

### Materials

- ESP32-C3-DevKitM-1
- Full-size breadboard
- TFT display, 240x320

### Check for understanding

Each student finishes "Springs" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Critical damping".

Chapter 3. About 1 h 40 min

## Friction and rigid bodies

Stick and slip on a rolling deck, then bodies that turn as well as move.

Lesson | Time | What students do

Friction Slide a crate to a stop, find the angle where static friction lets go, and ride a cargo crate on the deck of a ship rolling in a swell. | 55 min

- Slide to a stop
- Hold or slip
- A rolling ship
- A slippery deck
- Grippy feet

Rigid bodies Give a body an angle and a spin: moment of inertia, torque from an off-center kick, and contact impulses that make a solar panel tumble and settle. | 45 min

- How hard to spin
- Kick it off center
- Tumble onto the deck
- Move the kick

### Materials

- ESP32-C3-DevKitM-1
- Full-size breadboard
- TFT display, 240x320

### Check for understanding

Each student finishes "Rigid bodies" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Move the kick".

Chapter 4. About 55 min

## Boss

An MPU6050 tips a tray of marbles: the whole engine in one loop.

Lesson | Time | What students do

Boss: a tilt-driven sandbox Tilt the board and a tray of marbles rolls downhill: an MPU6050 sets gravity, and integration, collisions, restitution and rolling do the rest. | 55 min

- Wake the sensor
- Tip it right
- Tip it toward you
- Let them settle
- More marbles

### Materials

- Accelerometer and gyroscope, MPU6050
- ESP32-C3-DevKitM-1
- Full-size breadboard
- TFT display, 240x320

### Check for understanding

Each student finishes "Boss: a tilt-driven sandbox" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "More marbles".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
