Draw A Sprite PICO-8 Tutorial

Today we are going to draw a sprite to the screen with PICO-8.

First of all, what is a sprite? Sprites are little pictures we draw to the screen to make games. Usually sprites represent characters, enemies, or other things we want to animate on screen.

Most 2D games involve drawing many sprites on the screen to make up the visual portion of the game. Thus, drawing sprites is fundamental to making PICO-8 games.

Let’s get started…

First thing is to start PICO-8 and go to the code editor. Type the following code:

cls()
spr(0,64,64)

Now run the code. It should clear the screen and draw the default sprite in the middle of the screen.

Next, let’s make our own sprite and draw that. Go into the sprite editor tab in PICO and click on the second sprite box (number 001). Draw whatever you want. For the above video demo I’m drawing a smiley face.

After you are done making your own sprite, go back to the code tab and change your code to the following:

cls()
spr(1,64,64)

That should output your sprite to the screen. Notice that the difference is we are using sprite number 1 instead of 0. By default PICO-8 can have up to 128 sprites on the sprite sheet, so that is plenty for most small games.

The other thing to notice is we call the spr() function with three arguments. The first argument is our sprite index. The next two are the x and y coordinates where the sprite is drawn on screen.

Go ahead and change the x, y coordinates of your sprite like this:

cls()
spr(1, 10, 100)

That should output your sprite to the bottom left of the screen. The x coordinates go from 0 to 127 from left to right. The y coordinates go from 0 to 127. PICO-8’s resolution is 128x128.

Alright, so that is drawing a sprite to screen with PICO-8. To further explore this idea, mess around with drawing multiple sprites to screen.

Have fun!

<- PICO-8 Tutorials

© Brian Knapp 2024