There are many ways to achieve this and it's definitely down to personal preference.
A method I used at times is an array, which means I can set off multiple explosions at the same time and all will run independently until their size condition is met, then it's deleted to make way for another explosion.
This takes only one image of an explosion and two functions, one which is called with the X, Y to establish the explosion and another which progresses it through it's scale until it's big and I want to remove it.
The code snippet here allows for 50 explosions at once.
You just need a 'explosion.png' image in your media folder around 200x200 in size, a mature explosion, as the function will start it at a low scale, which gives you the impression it's exploding when the scale increases.
Cheers, Ian.
rem Resolution
SetVirtualResolution (640,480)
rem set variables and arrays
Global Explosions
Global Dim Exp[50] rem holds the sprite id assigned to the explosion
Global Dim ExpX[50] rem holds the original X cordinate the explosion is at
Global Dim ExpY[50] rem holds the original Y cordinate the explosion is at
Global Dim ExpSize#[50] rem the starting scale of the explosion
Explosions = 50
Do
CreateExplosion(Random(0,1024),Random(0,576))
MoveExplosion()
Sync()
Loop
Function CreateExplosion(XX,YY)
NextOne = 0
For LL = 1 to Explosions
If GetSpriteExists(Exp[LL]) = 0 And NextOne = 0
NextOne = CreateSprite(LoadImage("explosion.png"))
ExpSize#[LL] = 0.1
SetSpriteScale(NextOne,ExpSize#[LL],ExpSize#[LL])
SetSpritePosition(Nextone,XX-(GetSpriteWidth(NextOne)/2),YY-(GetSpriteHeight(NextOne)/2))
Exp[LL] = NextOne
ExpX[LL] = XX
ExpY[LL] = YY
EndIf
Next LL
EndFunction
Function MoveExplosion()
For LL = 1 to Explosions
If GetSpriteExists(Exp[LL]) = 1
ExpSize#[LL] = ExpSize#[LL] + 0.1
Rem as soon as the explosion is over 1.0 in scale, delete it
If ExpSize#[LL] > 1.0
DeleteSprite(Exp[LL])
Exp[LL] = 0
Else
SetSpriteScale(Exp[LL],ExpSize#[LL],ExpSize#[LL])
SetSpritePosition(Exp[LL],ExpX[LL]-(GetSpriteWidth(Exp[LL])/2),ExpY[LL]-(GetSpriteHeight(Exp[LL])/2))
EndIf
EndIf
Next LL
EndFunction
www.zortokgames.com