Use the command LoadAnimImage to load the sprite sheet.
It needs the width and height of a single frame and the number of frames that the sheet contains.
Then, use the 4th parameter of DrawImage to select which frame to draw.
Sort of like this:
It needs the width and height of a single frame and the number of frames that the sheet contains.
Then, use the 4th parameter of DrawImage to select which frame to draw.
Sort of like this:
graphics 800, 600, 0, 2 setbuffer backbuffer() ;sprites are 64x64 and sheet contains 16 sprites sprites = loadanimimage("spritesheet.bmp", 64, 64, 0, 16) repeat cls ;draw current frame (frame+frameoffset) DrawImage sprites, x, y, frame + frameoffset ;on keyhit (first keydown), select frameoffset if keyhit(203) then frameoffset = 0: frame = 0 if keyhit(205) then frameoffset = 4: frame = 0 ;on keydown, move 'x' coordinate and loop the current frame between 0 and 3 (with 'mod 4') if keydown(203) then frame = (frame + 1) mod 4: x = x - 1 if keydown(205) then frame = (frame + 1) mod 4: x = x + 1 flip forever