Frames
A cartoon is just pictures shown quickly, one after another. Each picture is called a frame. Show enough of them fast enough and your eye sees movement.
That is all animation is. No magic.
In this milestone you don't print pictures — you hand them over. You write a
function called draw, and the computer calls it twenty times a second and puts
whatever you return on the screen.
blank_grid() gives you a fresh picture: blue sky with a strip of brown dirt at
the bottom. Your job is to change some squares and hand it back.
The picture is a list of lists
The grid is 14 rows tall and 40 columns wide. Each square holds a colour.
Rows count downward. Row 0 is the very top of the sky. Row 13 is the
bottom, down in the dirt.
To colour a square, assign to it:
You can use ordinary colour names — "red", "gold", "lime", "white" — or
codes like "#ff8800".
Two helpers you already have
WIDTH is 40. HEIGHT is 14. GROUND is 12 — the row things stand on.
Use those names instead of typing the numbers. If you write for col in range(40) and the grid ever gets wider, your code breaks. range(WIDTH) keeps
working.
One rule that catches everyone
draw must return the grid. Colouring squares changes the picture, but if
you forget to hand it back the computer gets nothing:
You'll see: "draw() didn't return anything. Add 'return grid' as its last line."
That message is your friend. It will find you at least once today.