Workshop › Zelda-style Dungeon › Step 9 of 22
Each e in a room becomes an enemy when you enter it: a purple square the size of the hero. An enemy remembers a lot
that the next steps will use: which way it walks, when it turns, its health, and a knock-back.
```js
let enemies
enemies = []
ROOMS[ry][rx].forEach((line, row) => {
;[...line].forEach((ch, col) => {
if (ch !== 'e') return
const x = col * T + (T - SIZE) / 2
enemies.push({ x, y: row * T + (T - SIZE) / 2, dir: [1, 0], turnIn: 0, hp: 1, knock: 0, kx: 0, ky: 0 })
})
})
for (const e of enemies) {
ctx.fillStyle = e.knock > 0 ? '#fca5a5' : '#7c3aed'
ctx.fillRect(e.x, e.y, SIZE, SIZE)
}
```e still is), not from tiles.knock > 0) is drawn pale pink.player, write enemies.enter, after tiles, build the enemies.draw, draw them before the hero.Skills: Arrays and objects, Drawing on a canvas