Workshop › Wolfenstein-style 3D Maze › Step 5 of 18
Up (or W) walks forwards in the looking direction, Down (or S) backwards. The step is the direction's cos and sin times the speed. Walls don't stop you yet.
```js
const MOVE = 0.05 // tiles per frame
function move(dx, dy) {
player.x += dx
player.y += dy
}
const forward = (keys.ArrowUp || keys.w ? 1 : 0) - (keys.ArrowDown || keys.s ? 1 : 0)
if (forward !== 0) move(Math.cos(player.angle) * MOVE * forward, Math.sin(player.angle) * MOVE * forward)
```forward is 1 (up held), -1 (down held) or 0 (neither, or both).Math.cos(angle) * MOVE is how much of the step goes across, Math.sin(angle) * MOVE how much goes down.forward, so walking backwards is the same step reversed.TURN, write MOVE.move.update, write the two walking lines.Skills: Keyboard and mouse input, Velocity and gravity