Workshop › Wolfenstein-style 3D Maze › Step 7 of 18
Now move asks before moving. Across and down are asked separately: walking diagonally into a wall stops only the
part that would enter it, so the player slides along the wall instead of sticking to it.
```js
// Moving each axis on its own lets the player slide along a wall instead of sticking to it.
function move(dx, dy) {
if (!blocked(player.x + dx, player.y)) player.x += dx
if (!blocked(player.x, player.y + dy)) player.y += dy
}
```! means "not": move when it is not blocked.Replace the body of move with the two checks, and write the comment above it.
Skills: Collision detection
← Is it a wall? A ray: where it starts →