Brainlag Plans
  1. Web
  2. Build an app
36/39 lessons

Canvas, timers and random numbers

40 min4 exercisesPlus

Draw squares on a canvas with fillRect and clearRect, repeat work with setInterval and stop it with clearInterval, and pick a random grid cell.

The skill
Draw a game board on a canvas and move things on it with a timer.
You make
A painted grid, a countdown that stops, food on a random cell and a jumping mole.

Brainlag Plus lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 35 State and render: the data is the truth. Free to try: Web Foundations and the playground.

Step 1 of 8
exercise_1.html

You've reached the good stuff.

4 exercises in this lesson, checked as you type. Brainlag Plus opens every lesson after Foundations, in all four courses.

HTML, CSS and JavaScript