Canvas, timers and random numbers
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.
Passed
You can now
You have what you need for a project: Snake on a canvas Brainlag Plus 3 hours
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