Sprites tutorial

We'll draw a tile, place it on screen, and move it with the arrow keys. Total time: about 5 minutes.

1. Open the starter cart

The starter is a cart that draws sprite tile 0 at (64, 64) and moves it with arrow keys. You'll edit the tile in the Sprites tab.

variable x  64 x !
variable y  64 y !
: update
  0 cls
  2 btn if x @ 1 - x ! then  ( left  )
  3 btn if x @ 1 + x ! then  ( right )
  0 btn if y @ 1 - y ! then  ( up    )
  1 btn if y @ 1 + y ! then  ( down  )
  0 x @ y @ 0 sprite ;   ( tile=0  x  y  flags=0 )

2. Edit tile 0

Switch to the Sprites tab. The 256-tile sheet is on the right; tile 0 is highlighted. Draw whatever you like in the 8×8 canvas; each pixel is a palette index 0–15. Index 0 renders as transparent in sprite.

3. Hit Compile, then Run

Your tile shows up in the preview. Use arrow keys to move it.