Workshop › Bomberman-style Arena › Step 34 of 42
About one crate in five hides a power-up: 'bomb' (one more bomb at a time) or 'fire' (longer flames). They are
kept in a Map from a tile to its item; only tiles that have something take space.
```js
let items // 'r,c' -> 'bomb' or 'fire', hidden under crates until they burn
const key = (r, c) => r + ',' + c
items = new Map()
else {
grid[r].push('+')
if (Math.random() < 0.2) items.set(key(r, c), Math.random() < 0.5 ? 'bomb' : 'fire')
}
```Map stores values under keys: set(key, value), get(key), has(key), delete(key).key(3, 5) is '3,5'.{ }: place the crate, then a 20% chance to hide an item, half
bombs and half fire.let grid write let items; above near write key.makeGrid, under grid = [], write items = new Map().else grid[r].push('+') with the else { ... } block.Skills: Arrays and objects, Game states
← All enemies gone Uncover the power-ups →