Workshop › Bomberman-style Arena › Step 24 of 42
Now the flames are dangerous: standing in one costs a life and sends the player back to the start. "In a flame" means a flame on the player's tile, the nearest tile to where it is.
```js
let lives
lives = 3
const inFlames = (m) => {
const t = tileOf(m)
return flames.some((f) => f.r === t.r && f.c === t.c)
}
function hurt() {
lives -= 1
player = { x: 1, y: 1, target: null }
}
if (inFlames(player)) hurt()
```{ } and a return.flames.some(...) asks whether at least one flame is on that tile.hurt takes a life and puts a fresh player back at the start.let power write let lives; in reset, under power = 2, write lives = 3.function update() { write inFlames and hurt.update, write the if (inFlames(player)) line.Skills: Collision detection, Game states
← Bombs blink A moment of safety →