SSPR


sspr = "stretch sprite"

sspr( sx, sy, sw, sh, dx, dy, [dw, dh], [flip_x], [flip_y] )
sx sprite sheet x position (in pixels)
sy sprite sheet y position (in pixels)
sw sprite width (in pixels)
sh sprite height (in pixels)
dx how far from the left of the screen to draw the sprite
dy how far from the top of the screen to draw the sprite
dw (optional) how many tiles wide to draw the sprite (default same as sw)
dh (optional) how many tiles tall to draw the sprite (default same as sh)
flip_x (optional) boolean, if true draw the sprite flipped horizontally (default false)
flip_y (optional) boolean, if true draw the sprite flipped vertically. (default false)

This function will draw a sprite of a specific size to a specific size from the sprite sheet to the screen.

SX, SY, SW, SH

These four arguments must be passed when calling this function. All of them deal with the sprite sheet space. The (sx,sy) are the coordinates of where to take the sprite from the sprite sheet. It will take a rectangle of the sprite sheet starting from the top left corner at (sx,sy) and with a width and height of (sw,sh).


DX, DY, DW, DH

The (dx,dy) arguments are required to draw the sprite at those coordinates on the screen. The (dw,dh) arguments are optional since they default to the same width and height from the sprite sheet, what you give as (sw, sh). In most cases, you will want to simply draw the sprite exactly the same size as it appears in the sprite sheet. However, these 2 arguments (sw, sh) allow you to stretch and squash the sprite to different sizes, something that spr() cannot do. That is why you may want to use sspr() even for standard size sprites.


FLIP_X, FLIP_Y

When flipping the sprite, horizontally or vertically, the screen position (dw,dh) is not changed, only how the sprite is drawn at this same coordinates. Note that you must provide draw width and draw height arguments before these flip arguments, even if you want the default sprite width and height.



Example:

-- 16x16 sprite
sx=8
sy=8
sw=16
sh=16
dx=10
dy=20
sspr( sx,sy, sw,sh, dx,dy )

-- 6x5 sprite
sx=8
sy=8
sw=6
sh=5
dx=10
dy=20
sspr( sx,sy, sw,sh, dx,dy )


1194

29 Apr 2024

Font