# CAMERA

``camera( x , y )``
 x the amount of horizontal offset. y the amount of vertical offset.

This function will offset the position of all drawing operations ( all Shapes, Print, Sprites, and Maps ). It will offset previously drawn elements as well, unless `camera` was called earlier.

Examples:

``````cls()                    --clear screen
rectfill(0,0,127,127,2)  --dark purple background
rect(0,0,127,127,8)      --red outline
print("camera(0,0)",2,2)``````

This first example clears the screen, then draws a filled rectangle the same size of the viewable screen, then draws a rectangle in red to outline the viewable screen. We do not call the camera function yet, so everything we draw is using the default camera offset of `(0,0)`, meaning no offset.

``````cls()                    --clear screen
rectfill(0,0,127,127,2)  --dark purple background
rect(0,0,127,127,8)      --red outline
print("camera(0,0)",2,2)

camera(63,63)                 --start camera offset
rect(63,63,127+63,127+63,11)  --new camera outline
print("camera(63,63)",136,182)``````

This second example we then start to use the camera function with an offset of `(63,63)`, which you could imagine moves the camera's top-left corner to the point `(63,63)`, however it actually subtracts the X and Y offsets from all draw operations.

We draw a new rectangle, in green this time, to outline the new viewable screen adjusting for the camera offset.

Notice that the previously drawn elements (before calling `camera`) has been shifted up and to the left. They have been affected by this new camera offset even though they were already drawn.

``````cls()
camera()                 --set first camera
rectfill(0,0,127,127,2)
rect(0,0,127,127,8)
print("camera(0,0)",2,2)

camera(63,63)            --set second camera
rect(63,63,190,190,11)
print("camera(63,63)",136,182))``````

This third example adds a camera right after clearing the screen, and sets the default offset of `(0,0)`. The rest of the code is the same as the second example. However, you'll notice that the first set of draw operations (the dark purple and red outlined rectangle) is no longer being offset by the second camera. They have been locked into position by the first call to `camera()`

Using two cameras this way is useful when you want to create a game screen that is offset using the camera function, and then draw a locked overlay such as health, points, etc. that is not affected by the main camera offset.

`Font`