Sets the camera offset in the draw state.
- The x offset, in pixels, to subtract from future draw coordinates. (default 0)
- The y offset, in pixels, to subtract from future draw coordinates. (default 0)
Setting a camera offset causes all subsequent draw operations to have the offset subtracted from their x and y coordinates.
camera() works is somewhat unintuitive. You might think you're placing the camera relative to the screen, but you're actually moving the screen relative to the camera. So, you might expect to use
camera(64,64) to put the camera origin in the middle of the screen, but you'd actually use
camera(-64,-64) to move the screen so that its middle is in front of the camera.
Camera offsets can be used to implement screen effects such as parallax scrolling (with a different offset per layer) or screen shake (a small random offset per frame).
-- draw a dark blue circle at (20, 20) circfill(20, 20, 10, 1) camera(-2, 2) -- draw a white circle at (22, 18) circfill(20, 20, 10, 7) camera(-64, -64) -- draw a big red circle, centered circfill(0, 0, 63, 8)