Workshop › Bomberman-style Arena › Step 7 of 42
About 45% of the free tiles get a crate, at random. Crates are drawn brown, with a darker stripe.
```js
else if (Math.random() > 0.55) grid[r].push(' ')
else grid[r].push('+')
ctx.fillStyle = tile === '#' ? '#475569' : tile === '+' ? '#b45309' : '#3f6212'
ctx.fillRect(x, y, TILE, TILE)
if (tile === '+') {
ctx.fillStyle = '#92400e'
ctx.fillRect(x + 4, y + 14, TILE - 8, 4)
}
```Math.random() gives a random number between 0 and 1; > 0.55 is true 45% of the time: floor. Otherwise a crate.? : in a row pick one of three colors.makeGrid, replace else grid[r].push(' ') with the two new lines.draw, extend the color and, under the tile's fillRect, write the stripe.Skills: Arrays and objects, Drawing on a canvas
← Pillars Keep the corners clear →