Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Scroll With Camera?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/blit386-scroll-with-camera)
---
name: scroll-with-camera
description:
Scroll a world larger than the screen using the global camera offset and keep it clamped inside the world bounds. Use
for side-scrollers, top-down maps, or any level bigger than the screen that should follow the player.
---
# Scroll with a camera
Move a single global offset so a world larger than the screen scrolls, then keep it inside the world's edges.
## How to do it
Set the camera in `update()`, draw the world in `render()`, then reset the camera before the HUD:
```js
async init() {
// ...
this.worldSize = new Vector2i(1280, 960);
return true;
}
update() {
// ...move the player...
// Center the camera on the player, then clamp so it never shows past the world edge.
const wanted = new Vector2i(
this.player.x - Math.floor(BT.displaySize.x / 2),
this.player.y - Math.floor(BT.displaySize.y / 2),
);
BT.cameraSet(BT.cameraClamp(wanted, this.worldSize));
}
render() {
BT.clear(COLOR_BACKGROUND);
// Draw in WORLD coordinates - the camera offset is applied for you.
BT.drawRectFill(new Rect2i(this.player.x, this.player.y, 16, 16), COLOR_PLAYER);
BT.cameraReset(); // back to screen space: the HUD below does not scroll
BT.systemPrint(new Vector2i(6, 6), COLOR_TEXT, `Score ${this.score}`);
}
```
The reset only lasts until the next `update()` sets the camera again, so the world keeps scrolling on the next frame.
## Key calls
- `BT.cameraSet(offset)` (method) - set the global scroll offset (`Vector2i`).
- `BT.camera` (getter) - the current offset.
- `BT.cameraReset()` (method) - back to `(0, 0)`.
- `BT.cameraClamp(camera, worldSize, viewSize?)` (method) - return an offset kept inside the world bounds.
## Notes
- Draw everything in world coordinates; the camera shifts the whole frame.
- For a fixed HUD or mini-map, draw it after `BT.cameraReset()` so it does not scroll.
- Offsets are whole numbers.
- For a camera that glides instead of stepping on a fast screen, see the `smooth-the-motion` skill.
See `docs/input.md` for moving the player.