Spritestrip Packer

BlitzMax Forums/BlitzMax Programming/Spritestrip Packer

zoqfotpik(Posted 2013) [#1]
Here's a very basic tool for packing horizontal spritestrips into one spritesheet. Posted another version of this, this one is much simplified.

' spritestrip packer
Graphics 1152,600
Global SPRITESHEET$="catsprites.png"
Global TERRAINSHEET$="castlescaled.png"
Global BACKGROUNDSHEET$="junglescaled.png"
Global MONSTERSHEET$="knightscaled.png"
Global TRAPSHEET$="trapsscaled.png"
Global TREASURESHEET$="treasuresprites.png"
Global ynum:Int=0
Global finalsheet:TImage = CreateImage(1152,600)
Global SPRITESIZE=48

SetClsColor 255,0,128
Cls
Loadanddraw(SPRITESHEET)
Loadanddraw(terrainsheet)
Loadanddraw(backgroundsheet)
Loadanddraw(monstersheet)
Loadanddraw(trapsheet)
Loadanddraw(treasuresheet)
GrabImage finalsheet,0,0

mypixmap:TPixmap = GrabPixmap (0,0,1152,600)
mypixmap = MaskPixmap(mypixmap,255,0,128)
SavePixmapPNG(mypixmap,"packedsheet.png")

finalsheet = LoadImage("packedsheet.png")  ' Reloading image we just saved to verify
While Not KeyDown (KEY_ESCAPE)
Cls
DrawLine 0,0,1000,600  ' this is to check whether sheet was successfully transparent
DrawImage finalsheet,0,0
ynum=0

Flip
Delay 1000
Wend
 
Function Loadstrip:TImage(name:String)
	Local tempimage:TImage = LoadImage(name)
	Return tempimage
End Function

Function Loadanddraw(name:String)
	Local tempimage:TImage = loadstrip(name)
	DrawImage(tempimage), 0, ynum
	ynum = ynum + SPRITESIZE
End Function




Hardcoal(Posted 2013) [#2]
Thats good if thats what i think it is!


zoqfotpik(Posted 2013) [#3]
Well, all it does is take separate sprite strips and combine them into a single image. It's not for oddly shaped sprites or anything complex, just a basic tool.

Oddly enough, after I did this and converted my strip-based engine to use a single sheet, I didn't notice any framerate difference, but then again that's on a PC and mobiles use much less beefy hardware.


Hardcoal(Posted 2013) [#4]
yea as simple as it is
its useful