Workshop › Mario-style Platformer › Step 20 of 37
The camera must never show beyond the ends of the level: we clamp it between 0 and COLS * TILE - canvas.width.
```js
camera = clamp(player.x + player.w / 2 - canvas.width / 2, 0, COLS * TILE - canvas.width)
```COLS * TILE is the level's width, 2048; minus the screen's width it is the largest camera, 1408.In update, wrap the camera expression in clamp(..., 0, COLS * TILE - canvas.width).
Skills: Game states
← A camera that follows Draw only what is on screen →