Here's an example of how you'd generate a sprite sheet for any amount of frames at any size:
set text size 32
dim sprFrames(12)
`generate sprite sheet
uniformFrameSize = 128 `the size of the frame width and height
sheetSubdivisions = 4 `how many frames per row/column
maxSubdivisions = 32
`POSSIBLE SAFETY METHOD
`basically this just checks to see if all the frames can fit in the size of the image,
`if not it will increse the number of frames that can possibly fit by row, also increasing the
`overal size of the image
if array count(sprFrames()) > (sheetSubdivisions^2)
for n = 0 to maxSubdivisions
inc sheetSubdivisions
if array count(sprFrames()) < (sheetSubdivisions^2) then exit
next
endif
`Further Safety
`set a limit to how big an image can be, if the frame number goes over that,
`make a way to set those frames to another spritesheet
uniformSheetSize = uniformFrameSize * sheetSubdivisions `actual uniform size of the image
spriteSheet = find free image()
make image spriteSheet, uniformSheetSize, uniformSheetSize
`since it's a render target we can draw directly to it
draw to image spriteSheet
for f = 0 to array count(sprFrames())
px = x * uniformFrameSize
py = y * uniformFrameSize
`#### here is where you'd set the frame and paste the sprite(f) at px, py ####
ink rgb(rnd(192),rnd(192),rnd(192)), 0
box px, py, px+uniformFrameSize, py+uniformFrameSize
ink rgb(255,255,255), 0
text px, py, str$(count)
inc count
`this just shifts the rows and columns
`reason for this method is it's easier to end than
`2 sperate loops for the row and columns set with an arbitrary number
oldx = x : x = wrap(x+1, 0, sheetSubdivisions-1)
if oldx > x
y = wrap(y+1, 0, sheetSubdivisions-1)
endif
next
draw to bitmap 0
`then save image it and BOOM!!!
paste image spriteSheet, 0, 0
wait key
end
Now if you're dealing with frames that are all different sizes there are algorithms for packing rectangles out there.
Also another method is visually editing the sprite sheet and placing where you want to the frames to be on it. Takes alitte more time but least you have more control and frames don't have to be uniform.
"Get in the Van!" - Van B