PICO-8 Wiki
Advertisement

The _draw() function is the second part of the game loop.

If a cartridge's source code includes both an _update() function and a _draw() function, then PICO-8 will attempt to call these functions once for each animation frame, at a rate of 30 frames per second (60 if _update60() is used.)

You define this function in your game's source code. It takes no arguments.

The intended purpose of _draw() is to draw the state of the game onto the screen, such as with calls to map() and spr(). A typical _draw() function starts with a call to cls() to clear the screen then draws all of the game elements, but this is not required.

If _update() and _draw() together take longer than 1/30th of a second (or 1/60th with _update60()) to complete, PICO-8 may decide not to call _draw() for a given frame. See the entry on the game loop.

The <code>_draw()</code> function is the second part of the game loop.

If a cartridge's source code includes both an <code>_update()</code> function and a <code>_draw()</code> function, then Pico-8 will attempt to call these functions once for each animation frame, at a rate of 30 frames per second (60 if <code>_update60()</code> is used.)

You define this function in your game's source code. It takes no arguments.

The intended purpose of <code>_draw()</code> is to draw the state of the game onto the screen, such as with calls to map() and spr(). A typical <code>_draw()</code> function starts with a call to cls() to clear the screen then draws all of the game elements, but this is not required.

If <code>_update()</code> and <code>_draw()</code> together take longer than 1/30th of a second (or 1/60th with <code>_update60()</code>) to complete, Pico-8 may decide not to call <code>_draw()</code> for a given frame. See the entry on the game loop.

Examples[]

function _draw()
  cls()
  print("hello, world!", rnd(76), rnd(124), rnd(15)+1)
end

See also[]

See also[]

Advertisement