PICO-8 Wiki
Advertisement
sspr( sx, sy, sw, sh, dx, dy, [dw,] [dh,] [flip_x,] [flip_y] )
Draws a rectangle of pixels from the sprite sheet, optionally stretching the image to fit a rectangle on the screen.
sx
The x coordinate of the upper left corner of the rectangle in the sprite sheet.

sy
The y coordinate of the upper left corner of the rectangle in the sprite sheet.

sw
The width of the rectangle in the sprite sheet, as a number of pixels.

sh
The height of the rectangle in the sprite sheet, as a number of pixels.

dx
The x coordinate of the upper left corner of the rectangle area of the screen.

dy
The y coordinate of the upper left corner of the rectangle area of the screen.

dw
The width of the rectangle area of the screen. The default is to match the image width (sw).

dh
The height of the rectangle area of the screen. The default is to match the image height (sh).

flip_x
If true, the image is drawn inverted left to right. The default is false.

flip_y
If true, the image is drawn inverted top to bottom. The default is false.

This operation is affected by the draw state.

Unlike spr(), this function uses pixel locations on the sprite sheet instead of sprite numbers. The sprite sheet is treated as an image 128 pixels wide and 128 pixels high, where (0, 0) is the upper left corner.

Examples

-- draw the 8 x 8 image from (8, 0) at screen location (60, 60)
sspr(8, 0, 8, 8, 60, 60)

-- draw the same image but stretched to 12 x 20 at screen location (44, 48)
sspr(8, 0, 8, 8, 44, 48, 12, 20)

-- draw it again, flipped horizontally, at (72, 48)
sspr(8, 0, 8, 8, 72, 48, 12, 20, true, false)
A demonstration of sspr.
The sprite sheet used in this example.

See also

Advertisement