print( string, x, y, color )
|color||a color number (0-15)|
The print() function is used to write strings to the game screen at the (x,y) position and in the color you specify. The default position is automatically set to the next line of the current cursor position. The default color is the current draw color set by either color() or any draw function with a color argument given. The default draw color when you startup PICO-8 is #6, light gray.
print("1 hello world") print("2 hello world",10,10) print("3 hello world",20,20,8) print("4 hello world",12)
These four lines of code show the different arguments you can pass to the
Line #1, we only pass the string,
"1 hello world" and PICO-8 will print that at the default position
(0,0) and default color
Line #2, we also pass the (x,y) coordinates of
(10,10) so it prints there and still with the default color
Line #3, we pass the string and the X and Y coordinates of
(20,20) and also include the color argument, setting the color to red
Line #4, we do something interesting and pass the string plus one more argument, which you might assume would be the X coordinate. However, PICO-8 is smart enough to accept this argument as the color, not the position! So it prints at a default position of the next line down from our last print (where the cursor left off) and in the color blue
(#12) which we specified.
12 Oct 2023