Skip to main content

Camera

cam!

Gets the camera position.

turbo::canvas
cam!() -> [i32; 2]

Get camera position

let [camera_x, camera_y] = cam!();

set_cam!

Sets the camera position.

turbo::canvas
set_cam!(x: i32, y: i32)
ParamTypeDefaultDescription
xi32[current x position]The camera x position in pixels
yi32[current y position]The camera y position in pixels

Set camera position

set_cam!(x = 0, y = 0); // set x and y position
set_cam!(x = 10); // set x position only
set_cam!(y = 10); // set y position only

move_cam!

Moves the camera relative to the current camera position.

turbo::canvas
move_cam!(x: i32, y: i32)
ParamTypeDefaultDescription
xi320The amount to adjust camera x position in pixels
yi320The amount to adjust camera y position in pixels

Move the camera

move_cam!(x = 4, y = 8); // move x position 4 pixels and y position 8 pixels
move_cam!(x = 10); // set x position 10 pixels
move_cam!(y = 10); // set y position 10 pixels