Workshop › Conway's Game of Life › Step 30 of 32
A phone has no keyboard, so the game gets a row of five buttons under the grid. We draw them from a list of names; the Play button reads Pause while the world runs.
```js
const BAR_Y = TOP + ROWS * CELL + 12 // the row of buttons
const BUTTONS = ['Play', 'Step', 'Random', 'Clear', 'Gun']
const BUTTON_W = canvas.width / BUTTONS.length
BUTTONS.forEach((label, i) => {
ctx.fillStyle = '#334155'
ctx.fillRect(i * BUTTON_W + 4, BAR_Y, BUTTON_W - 8, 36)
ctx.fillStyle = 'white'
ctx.font = 'bold 16px sans-serif'
ctx.textAlign = 'center'
ctx.fillText(label === 'Play' && playing ? 'Pause' : label, i * BUTTON_W + BUTTON_W / 2, BAR_Y + 24)
})
```BAR_Y is 12 pixels below the grid. BUTTON_W is 480 / 5 = 96, one fifth of the width each.forEach draws each button: a box starting at i * BUTTON_W, 4 pixels in from each side, 36 tall.textAlign = 'center' centres the label on x, the middle of the box.label === 'Play' && playing ? 'Pause' : label shows Pause on the Play button while the world runs.const TOP = 36 write the three button constants.draw, after the two loops, leave an empty line and write the forEach block.Skills: Drawing on a canvas, Arrays and objects
← Fire the gun Tap the buttons →