NameSummary
debug_print Draws a quick debug string at the top-left of the screen.
draw_image Draws an image onto the screen at the specified coordinates.
draw_rect Draws a filled rectangle using the vector engine.
draw_text Draws text using a specific font and color.
get_fps Returns the current actual frames per second.
init Initializes the game window with the given size and title.
is_key_pressed Returns true if the specified keyboard key is currently held down.
load_font Loads a TTF or OTF font file.
load_image Loads an image from the specified file path.
measure_text Returns the dimensions of the text if rendered with the given font.
run Starts the game loop.
fn debug_print(screen, text) -> null
Draws a quick debug string at the top-left of the screen.
Parameters
screenThe screen image.
textThe text to print.
Returns
null
fn draw_image(screen, image, x, y) -> null
Draws an image onto the screen at the specified coordinates.
Parameters
screenThe target screen image.
imageThe image to draw.
xX coordinate.
yY coordinate.
Returns
null
fn draw_rect(screen, x, y, w, h, r, g, b, a) -> null
Draws a filled rectangle using the vector engine.
Parameters
screenThe target screen image.
xX position.
yY position.
wWidth.
hHeight.
r, g, b, aColor components (0-255).
Returns
null
fn draw_text(screen, font, text, x, y, r, g, b, a) -> null
Draws text using a specific font and color.
Parameters
screenThe target screen image.
fontThe Font object to use.
textThe string to draw.
xX coordinate.
yY coordinate.
r, g, b, aOptional color components (0-255).
Returns
null
fn get_fps() -> float
Returns the current actual frames per second.
Returns
float
fn init(width, height, title) -> null
Initializes the game window with the given size and title.
Parameters
widthWindow width in pixels.
heightWindow height in pixels.
titleWindow title string.
Returns
null
fn is_key_pressed(key) -> bool
Returns true if the specified keyboard key is currently held down.
Parameters
keyKey name (e.g. 'SPACE', 'A', 'UP').
Returns
bool
fn load_font(path) -> result<Font>
Loads a TTF or OTF font file.
Parameters
pathPath to font file.
Returns
result<Font>
fn load_image(path) -> result<UserObject>
Loads an image from the specified file path.
Parameters
pathPath to image file.
Returns
result<UserObject>
fn measure_text(font, text) -> map{w, h}
Returns the dimensions of the text if rendered with the given font.
Parameters
fontThe Font object.
textThe text string.
Returns
map{w, h}
fn run(update_fn, draw_fn) -> result<null>
Starts the game loop. Takes an update function and a draw function.
Parameters
update_fnFunction called every tick.
draw_fnFunction called every frame (receives screen).
Returns
result<null>