Quote: "you can only fly along the X and Y axis"
First of all, if it's a top down 3D view then you are flying along the X and Z axis - not X and Y.
Quote: "but can zoom in and out on the Z axis"
You would also be zooming in on the Y axis. Minor points I know, but important for what you have to do.
For the size of the sprite, simply base it on the distance between the camera and the exploding object. The greater the distance, the smaller the sprite. Something like:
Rem Sprite Explosion Size Based On Distance Example For DBC
Rem By TDK_Man March 2007
Set Display Mode 800,600,16
Sync On: Sync Rate 0: CLS 0
Hide Mouse
AutoCam Off
Backdrop On
Color Backdrop 0
Position Camera 0,90,0
Point Camera 0,0,0
Rem Load Sprite Explosion Image Set - 45 frames starting at image number 1001
For N=1 To 45
ImgFilename$="Explosion\Frame"+Str$(N)+".jpg"
Load Image ImgFilename$,1000+N
Next N
Rem Make 20 objects at increasing distances
For N=1 To 20
Make Object Sphere N,12
Color Object N,RGB(0,40,90)
XPos=(N-5)*20
YPos=0-(N*30)
ZPos=0
Position Object N,XPos,YPos,ZPos
Next N
Rem Create an off-screen sprite for the explosion
SprWidth=320: SprHeight=240
SPRITE 1,-320,0,1001
SET SPRITE 1,1,1
SIZE SPRITE 1,SprWidth,SprHeight; Rem size for closest explosion - smaller the further away
Wait Key: Rem Press any key to start explosions
Rem Blow up all objects
For I=1 To 20
Rem Calculate distance of object
x# = Object Position X(I) - Camera Position X()
y# = Object Position Y(I) - Camera Position Y()
z# = Object Position Z(I) - Camera Position Z()
ObjDist# = Sqrt(X#^2+Y#^2+Z#^2)
Rem Calculate size of explosion sprite based on distance
Size = SprWidth * (1.0 / ObjDist#)*30
Rem Resize the sprite
SCALE SPRITE 1, Size
Rem Calculate position of 2D sprite based on current object's 3D screen position
ExpPosX = Object Screen X(I)-Sprite Width(1)/2
ExpPosY = Object Screen Y(I)-Sprite Height(1)/2
Gosub Explosion
Next N
End
Explosion:
Rem Display sprite animation
Rem Note: For continuity, in a game with many explosions, this proc would not be able to use a For .. Next loop
Rem but instead would be called once per loop and use frame counting variables
SPRITE 1,ExpPosX,ExpPosY,1001
Delete Object I
For N=1002 To 1045
SPRITE 1,ExpPosX,ExpPosY,N
Sync
Next N
SPRITE 1,-320,0,1001
Return
Save this code snippet as a DBA file in the same folder as the snippet I posted in the other thread as it uses the same explosion image set for the sprite.
TDK_Man