Workshop › Pac-Man-style Maze Chase › Step 10 of 42
Move every frame
What we are doing
update runs once per frame and advances the player. The player's choose function, choosePlayer, stops it in
front of a wall. The loop calls update before draw.
```js
function choosePlayer(p) {
if (!canGo(p, p.dir)) p.dir = STOP
}
function update() {
advance(player, choosePlayer)
}
function loop() {
update()
draw()
```
What it means
choosePlayer is what advance calls at each tile center: if the way ahead is a wall, the player stops.
update moves the player one frame; loop now updates, then draws.
Your turn
Under advance, leave an empty line and write choosePlayer.