Workshop › Pac-Man-style Maze Chase › Step 6 of 42
The player is an object with a column and a row. placeActors finds the P in the map and puts the player there;
draw paints a yellow circle on that tile.
```js
let player
function placeActors() {
const row = MAZE.findIndex((line) => line.includes('P'))
player = { col: MAZE[row].indexOf('P'), row }
}
function reset() {
fillPellets()
placeActors()
}
ctx.fillStyle = '#facc15'
ctx.beginPath()
ctx.arc(player.col * TILE + TILE / 2, TOP + player.row * TILE + TILE / 2, 10, 0, Math.PI * 2)
ctx.fill()
```findIndex returns the position of the first item for which the function is true: the row that contains 'P'.indexOf('P') is the position of P inside that string: the column.{ col: ..., row } is short for { col: ..., row: row }.let powers ... write let player.function reset() write placeActors; inside reset add placeActors().draw, after an empty line, write the four player lines.Skills: Game states, Drawing on a canvas
← Draw the pellets Where can you walk? →