Flip
- Copies the graphics buffer to the screen, then synchronizes to the next frame at 30 frames per second.
Carts that use the built-in game loop functions _update() and _draw() do not need to call flip()
. It can, however, be used to synchronize with the 30-frames-per-second draw timer in carts that implement their own custom game loop.
Note: If no _draw() function is implemented, PICO-8 will copy the graphics buffer to the screen 30 times per second automatically even if flip()
is not called as often. flip()
waits until the next frame has been copied, synchronizing program execution to the frame timer.
Examples
for x=4,124 do
cls()
circfill(x, x, 4, 8)
flip()
end
This example animates a circle moving diagonally across the screen, one pixel per frame for 120 frames (four seconds).
If the call to flip()
is removed, the code above clears the graphics buffer and draws the circle 120 times, but the buffer is only copied to the screen when the program exits.