Skip to content

STANNcam Manager

Jack Conradsen edited this page Feb 27, 2024 · 7 revisions

Initializing STANNcam

To start using STANNcam I recommend creating a new dedicated persistent camera object, or you can also use any Persistent manager object you have.  

stanncam_init(game_w, game_h, [resolution_w], [resolution_h], [gui_w], [gui_h], [window_mode])

Initializes stanncam with different resolutions.

Argument Type Description
game_w Integer The width of the actual game, this will be scaled up to match the resolution
game_h Integer The height of the actual game, this will be scaled up to match the resolution
[resolution_w] Integer The window resolution width
Default: same as game_w
[resolution_h] Integer The window resolution height
Default: same as game_h
[gui_w] Integer The GUI width resolution, can be independent of the game res
Default: Same as game_w
[gui_h] Integer The GUI height resolution, can be independent of the game res
Default: Same as game_h
[window_mode] STANNCAM_WINDOW_MODE The window mode can be either STANNCAM_WINDOW_MODE.WINDOWED, STANNCAM_WINDOW_MODE.FULLSCREEN, STANNCAM_WINDOW_MODE.BORDERLESS
Default: STANNCAM_WINDOW_MODE.WINDOWED

Example:

// GUI by default is identical to the game resolution
// So if that's what we want we can just not specify it
stanncam_init(320, 240, 1920, 1080);

It also sets these global variables which you can use throughout your game afterwards.

Global Var Description
global.stanncams Array containing all stanncam cameras
Default: -1
global.game_w Game width
global.game_h Game height
global.res_w Display resolution width, ie the final window size
global.res_h Display resolution height, ie the final window size
global.gui_w GUI width
global.gui_h GUI height
global.window_mode STANNCAM_WINDOW_MODE.WINDOWED, STANNCAM_WINDOW_MODE.FULLSCREEN, or STANNCAM_WINDOW_MODE.BORDERLESS

 

STANNcam Manager Methods

These methods control the global variables for STANNcam, and stuff such as resolution and setting whether the game should be fullscreened, borderless or windowed.

 

stanncam_set_resolution(resolution_w, resolution_h)

Changes the display resolution of the game. The game size will also scale to match the display resolution. This will keep everything looking pixel perfect!

Argument Type Description
resolution_w Integer Display/window resolution width
resolution_h Integer Display/window resolution height

 

stanncam_set_window_mode(window_mode)

Sets the game's display mode.

Argument Type Description
window_mode STANNCAM_WINDOW_MODE Possible display modes:
STANNCAM_WINDOW_MODE.WINDOWED, STANNCAM_WINDOW_MODE.FULLSCREEN, or STANNCAM_WINDOW_MODE.BORDERLESS

 

stanncam_set_windowed()

Sets the game to be displayed in a window.

 

stanncam_set_fullscreen()

Sets the game to be displayed at full screen.

 

stanncam_set_borderless()

Sets the game to be displayed in a borderless window.

 

stanncam_set_keep_aspect_ratio(on_off)

It sets whether the game should maintain it's aspect ratio. It is on by default.
If your game res is 640x480(4:3), but your display resolution is 1920x1080(16:9), then the game will be stretched out to match.
So if you don't want that you can toggle it on, this will effectively overwrite the display resolution to 1440x1080(4:3)

Argument Type Description
on_off Boolean either enables or disables it

 

stanncam_get_keep_aspect_ratio()

Returns whether or not keep_aspect_ratio is enabled.

Returns: Boolean

 

stanncam_fullscreen_ratio_compensate_x()

stanncam_fullscreen_ratio_compensate_y()

If keep_aspect_ratio is turned on, and the window is wider than the resolution.
Then the game wouldn't match the display resolutions, and so when drawing the game there would be a lot of black space on the right of the screen.
This methods returns half of that empty space, so the drawing can be offset and appear in the middle of the screen.
The stanncam.draw method already uses this by default, so it's rarely needed.

Returns: Float

 

stanncam_set_gui_resolution(gui_w, gui_h)

Changes the GUI resolution of the game. It also updates global.gui_w and global.gui_h.

Argument Type Description
gui_w Integer Width of the GUI resolution
gui_h Integer Height of the GUI resolution

 

stanncam_get_gui_scale_x()

stanncam_get_gui_scale_y()

How much bigger the GUI resolution is from the game resolution.

Returns: Float

 

stanncam_get_res_scale_x()

stanncam_get_res_scale_y()

How much bigger the Display resolution is from the game resolution.

Returns: Float

 

stanncam_toggle_cameras_paused()

Toggles whether or not to pause the stanncam camera.

Returns: Undefined

 

stanncam_set_cameras_paused(paused)

Sets whether or not to pause the stanncam camera.

Argument Type Description
paused Boolean Whether to pause or unpause all stanncam camera pause states

Returns: Undefined

 

stanncam_cameras_pause()

Pauses each stanncam camera.

Returns: Undefined

 

stanncam_cameras_unpause()

Unpauses each stanncam camera.

Returns: Undefined

 

Clone this wiki locally