Workshop › Bomberman-style Arena › Step 20 of 42
The explosion is a cross: from the bomb's tile, power tiles in each of the four directions. Each arm walks out
tile by tile; a wall stops it.
```js
let power
power = 2
for (const [dr, dc] of Object.values(DIRS)) {
for (let i = 1; i <= power; i++) {
const r = bomb.r + dr * i
const c = bomb.c + dc * i
if (grid[r][c] === '#') break
flames.push({ r, c, time: FLAME_TIME })
}
}
```Object.values(DIRS) is the list of the four steps: [[-1, 0], [1, 0], [0, -1], [0, 1]].power tiles out along one direction.break leaves the inner loop only: that arm ends and the next direction starts.{ r, c, time: ... } is short for { r: r, c: c, time: ... }.let maxBombs write let power; in reset, under maxBombs = 1, write power = 2.explode, under the first flame, write the two loops.Skills: Loops
← Flames die down Crates burn →