Here's an example. Import a png file to get a better idea of how it looks. Basically this creates a sprite and fades it for you.
Graphics3D 640,480
SetBuffer BackBuffer()
AppTitle "Smoke Effect Demonstration"
SeedRnd MilliSecs()
;Hopyfully this is understandable, I tried to use field names that were easily understood
Type smoke ;create a TYPE called smoke
Field smoke_sprite ;this is simply a name for the sprite that will be loaded
Field smoke_x ;starting x coordinate of sprite
Field smoke_y ;same for y
Field smoke_z ;and z
Field smoke_alpha# ;starting alpha of the sprite, make sure it is a float #
Field smoke_size# ;this will scale the sprite to a random # each time, make it a float also
Field smoke_vertical_speed# ;this is how fast the sprite will rise in altitude, make float also
Field smoke_horizontal_speed# ;this is how fast the sprite will go side to side, float #
Field smoke_fade_speed# ;and this is how fast the sprite will fade, make sure this is #
End Type
Global smoke_image = CreateSprite() ;for this demo, we'll use a simple flat sprite
;global smoke_image = LoadSprite("smoke.png") ;uncomment this and change smoke.png to your own sprite if you have one
SpriteViewMode smoke_image, 1 ;make it always face the camera
HideEntity smoke_image ;and hide this entity
camera = CreateCamera() ;create a camera
MoveEntity camera, 0,0,-30 ;move it backwards
;MAIN LOOP------------------------------
While Not KeyDown(1) ;while ESC is not pressed
user_input() ;this function gathers input from the user
update_smoke() ;this function updates each sprite
RenderWorld ;render the scene
hud() ;this function displays text information to the screen
Flip ;flip buffers
Wend
;END LOOP-------------------------------
Function user_input()
If KeyHit(57) ;if space is hit
For a = 1 To 5 ;create 5 sprites
billow.smoke = New smoke ;create a new SMOKE TYPE in a reference "container" named billow
billow\smoke_sprite = CopyEntity(smoke_image) ;copy the preloaded hidden sprite
billow\smoke_x = 0 ;place x coords
billow\smoke_y = 0 ;and y coords
billow\smoke_z = 0 ;and z coords
billow\smoke_alpha = 1 ;start the alpha at 1
billow\smoke_size = Rand(.3,2) ;pick a random number for scaling purposes
billow\smoke_vertical_speed = Rnd(.05,.15) ;pick a random vertical movement number
billow\smoke_horizontal_speed = Rnd(-.06,.06) ;pick a random horizontal movement number
billow\smoke_fade_speed = Rnd(.01,.03) ;pick a random fade speed
MoveEntity billow\smoke_sprite, billow\smoke_x, billow\smoke_y, billow\smoke_z ;move the entity to the picked coordinates
ScaleSprite billow\smoke_sprite, billow\smoke_size, billow\smoke_size ;scale it by the randomly generated scale size
EntityAlpha billow\smoke_sprite, billow\smoke_alpha ;and set the alpha to the picked alpha number
Next
End If
If KeyHit(28) ;if Enter is hit
billow.smoke = New smoke ;create a new SMOKE TYPE as above
billow\smoke_sprite = CopyEntity(smoke_image) ;copy the image again
billow\smoke_x = Rand(-7,7) ;place x coords
billow\smoke_y = Rand(-7,7) ;and y coords
billow\smoke_z = 0 ;and z coords
billow\smoke_alpha = 1 ;set alpha to 1
billow\smoke_size = Rand(4,6) ;pick a random number for scaling purposes
billow\smoke_vertical_speed = 0 ;this sprite isn't going to move, it's stationary
billow\smoke_horizontal_speed = 0 ;same note as above line
billow\smoke_fade_speed = .01 ;set fade speed
MoveEntity billow\smoke_sprite, billow\smoke_x, billow\smoke_y, billow\smoke_z ;move the entity to the picked coordinates
ScaleSprite billow\smoke_sprite, billow\smoke_size, billow\smoke_size ;scale it by the randomly generated scale size
EntityAlpha billow\smoke_sprite, billow\smoke_alpha
End If
If KeyHit(1) ;if ESC is hit
ClearWorld ;clear the world or scene
End ;and end the program
End If
End Function
Function update_smoke()
For billow.smoke = Each smoke ;for each SMOKE TYPE in the "container" billow
billow\smoke_alpha = billow\smoke_alpha - billow\smoke_fade_speed ;adjust to the new alpha
EntityAlpha billow\smoke_sprite, billow\smoke_alpha ;and SET the new alpha number
If billow\smoke_alpha < 0 ;if the alpha gets less than 0,
FreeEntity billow\smoke_sprite ;we'll free the sprite
Delete billow ;and delete it
Exit ;and exit, there's no need to continue for this sprite, it doesn't exist anymore
End If
MoveEntity billow\smoke_sprite, billow\smoke_horizontal_speed, billow\smoke_vertical_speed,0 ;and now update it's new location
Next
End Function
Function hud()
Text 0,0, "Press spacebar to create a rising smoke puff."
Text 0,20,"Press Enter to create a stationary smoke burst, like a flak explosion."
Text 0,40,"Import a smoke sprite to get a better idea of what this looks like."
End Function