Workshop › Wolfenstein-style 3D Maze › Step 2 of 18
The player stands at a point on the grid, measured in tiles: (1.5, 1.5) is the middle of the top-left floor tile. They also look in a direction, an angle. On the minimap they are a yellow dot with a line showing where they look.
```js
let player
function reset() {
player = { x: 1.5, y: 1.5, angle: 0 }
}
ctx.fillStyle = '#facc15'
ctx.fillRect(player.x * MINI - MINI / 4, player.y * MINI - MINI / 4, MINI / 2, MINI / 2)
ctx.strokeStyle = '#facc15'
ctx.beginPath()
ctx.moveTo(player.x * MINI, player.y * MINI)
ctx.lineTo((player.x + Math.cos(player.angle)) * MINI, (player.y + Math.sin(player.angle)) * MINI)
ctx.stroke()
reset()
```reset puts the player at the start; the game will call it again to play once more.MINI turns tiles into minimap pixels. The dot is 4×4, centered.Math.cos(angle) and Math.sin(angle) give the step one tile long in the looking direction: across and down.MINI, write player and reset.draw, draw the dot and the direction line.reset() above draw().Skills: Drawing on a canvas, Velocity and gravity
← The map Ceiling, floor and a loop →