Workshop › Conway's Game of Life › Step 25 of 32
Next we want to drag and paint a whole line. First we remember what the press decided: painting holds the value
being painted, 1 when you pressed on a dead cell and 0 (erase) when you pressed on a live one.
```js
let painting = null // while the pointer is down: the value being painted, 1 or 0
// Pressing on a dead cell paints live cells as you drag; pressing on a live one erases.
canvas.addEventListener('pointerdown', (event) => {
const cell = cellAt(toCanvas(event))
if (!cell) return
painting = grid[cell.r][cell.c] ? 0 : 1
grid[cell.r][cell.c] = painting
})
```painting starts as null: nothing is being painted.let frames write the painting line.pointerdown listener write the comment; inside it, replace the last line with the two painting lines.Skills: Game states
← Click a cell Drag to paint →