Workshop › Snake › Step 4 of 28
Snake moves on a grid: the 400-pixel board is 20 cells of 20 pixels each way. We name the cell size CELL and
draw one green cell: the snake's future head.
```js
const CELL = 20
ctx.fillStyle = 'lime'
ctx.fillRect(5 * CELL, 5 * CELL, CELL, CELL)
```const CELL = 20 names the cell size once, so we never repeat the number 20.5 * CELL is 100: column 5 starts 100 pixels from the left, row 5 starts 100 pixels from the top.CELLs make the square exactly one cell wide and tall.const ctx = ... leave an empty line and write const CELL = 20.lime lines. Press Run.Skills: Drawing on a canvas
← Paint the board Keep the position in a variable →