APIReference

From Pico-8 Wiki
Revision as of 09:59, 5 June 2016 by imported>Dddaaannn (API reference master article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

An API is a function provided by Pico-8 that you can call from a cartridge's source code. You can also call API functions from the Pico-8 command prompt, using function syntax.

Some APIs have optional arguments, indicated in this guide by square brackets around the argument name. To specify a value for an optional argument, you must specify values for all other arguments to the left in the argument list.

For example, the spr() function has three required arguments and four optional arguments:

spr( n, x, y, [w,] [h,] [flip_x,] [flip_y] )

This function can be called with three arguments, accepting the defaults for the others:

spr(1, 60, 60)

To specify a value for the flip_x argument, you must also specify w and h, even if you're using their default values:

spr(1, 60, 60, 1, 1, true)

The game loop

If you define these functions in your code, Pico-8 will call them at specific times. See game loop.

If your code doesn't use the game loop, you can call this function to copy graphics to the screen:

Graphics

Tables

Input

Sound

Map

Memory

Math

Cartridge data

Coroutines

Values and objects

Debugging

See also