Here's a blast animation control include file.
Use setupBlastImages() at the beginning then drawBlasts() and handleBlasts() in the loop. Try:
Use setupBlastImages() at the beginning then drawBlasts() and handleBlasts() in the loop. Try:
if mousehit(1) then blastHere(1,mousex(),mousey(),0.3)
; blast.bb Global small_blast_image Global large_blast_image Type blast Field x,y Field speed# Field frame#,kind End Type ; call this to create a blast animation at these coords ; using kind=1 will create a small burst ; using kind=2 will create a big explosion ; a speed of 0.3 is quite good. Function blastHere(kind,x,y,speed#) b.blast=New blast b\x=x : b\y=y b\kind=kind b\frame=0:b\speed=speed End Function Function handleBlasts() For b.blast=Each blast Select b\kind Case 1: max_frame=9 Case 2: max_frame=6 End Select If Int(b\frame) >= max_frame Delete b Else b\frame=b\frame+b\speed EndIf Next End Function Function drawBlasts() ; draw the blast animation at its current int(frame) For b.blast=Each blast Select b\kind Case 1:DrawImage small_blast_image,b\x,b\y,Int(b\frame) Case 2:DrawImage large_blast_image,b\x,b\y,Int(b\frame) End Select Next End Function ; call this once on setup Function setupBlastImages() small_blast_image=LoadAnimImage("gfx\gunsplater.png",32,32,0,10) large_blast_image=LoadAnimImage("gfx\frag.png",32,32,0,7) MaskImage small_blast_image,255,0,255 MaskImage large_blast_image,255,0,255 End Function