Workshop › Sokoban › Step 13 of 29
move(dx, dy) moves the player one tile: dx and dy say how far in each direction. A wall on the target tile
blocks the step.
```js
function move(dx, dy) {
const x = player.x + dx
const y = player.y + dy
if (walls.has(key(x, y))) return
player = { x, y }
}
```x and y are the target tile.walls.has(key(x, y)) asks the Set whether there is a wall there; if so, return leaves at once.Above function draw() {, write move and leave an empty line. Press Run.
Skills: Game states, Collision detection
← Two more levels Walk with the arrows →