This function allows you to load in a single image/sprite that contains a multiple of same size images (tiles etc.) and then spits out sprites ready to be used - this negates the need for lots and lots of similar image files within a folder and makes everything tidier and easier.
This code is public domain and may be used freely, although a thankyou would be nice.
USAGE -
AnimImage( graphic file name$, the required sprite start#, number of tiles/images, tile width, tile height]
// Get tiles
FUNCTION AnimImage: name$, start_num, num_sprites, width, height
LOADSPRITE name$,1000
DRAWRECT 0,0,640,480,RGB(255,0,128)
DRAWSPRITE 1000,0,0
GETSPRITESIZE 1000,sizex,sizey
n=start_num
x=0
y=0
WHILE n
GRABSPRITE n,x,y,width,height
n=n+1
x=x+width
IF x>sizex-width
x=0
y=y+height
ENDIF
IF KEY(1) THEN RETURN
WEND
ENDFUNCTION