PICO-8 Wiki
cls( [color] )
Clears the graphics buffer.
A color to use for the background. The default is 0 (black).

The cls() function clears the graphics buffer, effectively setting every pixel to the color 0. If the color argument is provided, that number is used instead.

cls() also sets the text cursor in the draw state to (0, 0).

This ignores the alternate palette set by pal() for the purposes of using color 0. (pal(0, 7) cls() does not fill the screen with white.) To fill the screen with a specific color, use rectfill.

It is common (though not required) to call cls() at the beginning of the _draw() function as part of the game loop.


function _init()
  x = 0

function _update()
  -- add 1 to x. if x > 128, reset it to 0.
  x = (x + 1) % 128

function _draw()
  circfill(x, x, 10, 8)

Try removing the cls() call from this example.

Cls example.gif

See also[]