Camera
The camera's global pixel offset and world-clamp helpers.
The camera applies a global pixel offset to all subsequent draw calls. Integer only - pass Vector2i, never floats.
BT.cameraSet Since 0.1.0
BT.camera Since 1.0.4
BT.cameraReset Since 0.1.0
BT.cameraClamp Since 1.0.3
.(new (, )); // apply offset
.; // Vector2i - current offset
.(); // set back to (0, 0)
// Clamp a camera origin so the viewport stays within a world:
const = .(, );
// Optional third argument overrides the viewport size (default: BT.displaySize):
const = .(, , new (160, 120));Camera persists across zero-update frames
BT.cameraSet()'s offset persists across render frames automatically, including frames where update() does not run -
common on high refresh-rate displays where render() outpaces the fixed update rate (see
Render frames with zero update() steps in API: Game Loop). Call
cameraSet() once per update() tick and cameraReset() at the end of render() to switch to screen space for UI
overlays, as the demos below do; the engine re-applies the last offset before the next render pass begins, so as long as
update() keeps calling cameraSet(), the reset never leaks into a later frame's world draw.
cameraReset() itself persists the same way, on a one fixed-update-tick delay: if nothing calls cameraSet() again by
the next tick, the camera offset becomes (0, 0) for every following frame, not just the rest of the current one - so a
screen that stops touching the camera altogether (a menu, a world map after a scrolling level) starts clean instead of
inheriting whatever offset the previous screen last scrolled to.
Standalone helper (same math as BT.cameraClamp):
clampCameraToWorld Since 1.0.3
const = (, , );Two more camera-driven demos: parallax scrolling and a scrolling tile grid.
API history
| Symbol | Since | Last changed | Status |
|---|---|---|---|
BT.camera | 1.0.4 | – | stable |
BT.cameraClamp | 1.0.3 | – | stable |
BT.cameraReset | 0.1.0 | 1.7.1 | stable |
BT.cameraSet | 0.1.0 | – | stable |
clampCameraToWorld | 1.0.3 | – | stable |
1.7.1 - Sun Sep 27 2026
- Changed
BT.cameraResetNow persists once nothing sets the camera again: previously, the offset the engine re-applies at frame start stayed at its pre-reset value forever, so a later frame that never calls `cameraSet` again still saw the old offset leak back in.
1.0.4 - Sun May 17 2026
- Added
BT.camera
1.0.3 - Sat May 16 2026
- Added
BT.cameraClamp - Added
clampCameraToWorld
0.1.0 - Sat Dec 13 2025
- Added
BT.cameraReset - Added
BT.cameraSet
See also
API: Core
API: Core Types
API: Rendering
Last updated on October 18, 2026