TileSprite

Previous topic - Next topic

Kitty Hello

This is the tilesprite function of BB. It only works with n^2 x m^2 sprites, though.
Code (glbasic) Select


DRAWRECT 0,0,63,31, RGB(128,255,255)
PRINT "foo", 0,0

GRABSPRITE 0, 0,0,64,32


LOCAL mx, my, b1, b2
WHILE TRUE
MOUSESTATE mx, my, b1, b2
TileSprite(0, mx, my)

DRAWSPRITE 0,0,0
SHOWSCREEN
WEND


FUNCTION TileSprite%: id%, dx%, dy%, scx%=0, scy%=0
LOCAL spx%, spy%
GETSPRITESIZE id%, spx%, spy%
IF scx<=0 OR scy<=0 THEN GETSCREENSIZE scx%, scy%



LOCAL w%, h%, c%
w = (scx / spx ) * spx
h = (scy / spy ) * spy

c% = RGB(255,255,255)
DEC dx, spx
DEC dy, spy
STARTPOLY id, FALSE
POLYVECTOR 0,     0, dx,     dy,     c%
POLYVECTOR 0,   scy, dx,     dy+scy, c%
POLYVECTOR scx, scy, dx+scx, dy+scy, c%
POLYVECTOR scx,   0, dx+scx, dy,     c%
ENDPOLY
ENDFUNCTION




Tags: Tileblock, blitz