Actually with some tweaking can be used for trails or clouds too
use cursor keys to adjust wind
Rem Project: Smoke
Rem Created: 30.05.2005 15:53:14
Rem ***** Main Source File *****
`Create smoke image
create bitmap 1,50,50
ink rgb(250,200,100),0
for x=1 to 1000
ang=rnd(360)
rad=rnd(20)
dot 25+sin(ang)*rad,25+cos(ang)*rad
next x
blur bitmap 1,4
img = free_image()
get image img,0,0,50,50
delete bitmap 1
Type Vectors
x As Float
y As Float
z As Float
EndType
Type Particle
p As Vectors
v As Vectors
sz As Vectors
Fade As Float
EndType
make matrix 1,1000,1000,20,20
position camera 0,20,-50
GOSUB makeSmoke
sync on
do
GOSUB loopSmoke
if leftkey() then windx# = windx# - 0.01
if rightkey() then windx# = windx# + 0.01
if upkey() then windz# = windz# + 0.01
if downkey() then windz# = windz# - 0.01
camera#=wrapvalue(camera#+0.3)
position camera -sin(camera#)*128.0,30,100+cos(camera#)*128.0
point camera 0.0,0.0,100+0.0
sync
loop
makeSmoke:
ttlPrc = 400
objPrc = free_object()
DIM Particles(ttlPrc) As Particle
`Make particles
for x=objPrc to objPrc+ttlPrc
make object plain x,10,10
`make object triangle x, -10, 0, 0, 0, 10, 0, 10, 0, 0
texture object x,img
hide object x
set object transparency x,3
ghost object on x,0
set object transparency x, 1
set alpha mapping on x, 100
next x
RETURN
loopSmoke:
`Loop through particles
for t=1 to ttlPrc
Particles(t).sz.x = Particles(t).sz.x + 0.5
Particles(t).sz.y = Particles(t).sz.y + 0.5
Particles(t).p.x = Particles(t).p.x + Particles(t).v.x + windx#
Particles(t).p.y = Particles(t).p.y + Particles(t).v.y
Particles(t).p.z = Particles(t).p.z + Particles(t).v.z + windz#
`Fade particle value
Particles(t).Fade = Particles(t).Fade - 1
`Position, scale and fade particle object
position object objPrc+t-1,Particles(t).p.x,Particles(t).p.y,Particles(t).p.z
scale object objPrc+t-1,Particles(t).sz.x,Particles(t).sz.y,100
fade object objPrc+t-1,Particles(t).Fade
`Point at camera
set object to camera orientation objPrc+t-1
next t
inc i
if i>ttlPrc then i=1
if Particles(i).Fade < 0
`Position
Particles(i).p.x = 0
Particles(i).p.y = 0
Particles(i).p.z = 100
`Scale
Particles(i).sz.x = 50
Particles(i).sz.y = 50
`Velocity (randomize)
Particles(i).v.x = rnd(100)/1000.0-0.1
Particles(i).v.y = rnd(200)/1000.0+0.1
Particles(i).v.z = rnd(100)/1000.0-0.1
Particles(i).Fade = ttlPrc / 2.0
`Show the particle
show object objPrc+i-1
endif
RETURN
Function free_object()
Repeat
Inc i
Until Object Exist(i) = 0
EndFunction i
Function free_image()
Repeat
Inc i
Until Image Exist(i) = 0
EndFunction i
Following is another version
Rem Project: Smoke
Rem Created: 30.05.2005 15:53:14
Rem ***** Main Source File *****
`Create smoke image
create bitmap 1,50,50
ink rgb(250,200,100),0
for x=1 to 1000
ang=rnd(360)
rad=rnd(20)
dot 25+sin(ang)*rad,25+cos(ang)*rad
next x
blur bitmap 1,4
img = free_image()
get image img,0,0,50,50
delete bitmap 1
Type Vectors
x As Float
y As Float
z As Float
EndType
Type Particle
p As Vectors
v As Vectors
sz As Vectors
Fade As Float
EndType
make matrix 1,1000,1000,20,20
position camera 0,20,-50
GOSUB makeSmoke
sync on
do
GOSUB loopSmoke
if leftkey() then windx# = windx# - 0.01
if rightkey() then windx# = windx# + 0.01
if upkey() then windz# = windz# + 0.01
if downkey() then windz# = windz# - 0.01
camera#=wrapvalue(camera#+0.3)
position camera -sin(camera#)*128.0,30,100+cos(camera#)*128.0
point camera 0.0,0.0,100+0.0
sync
loop
makeSmoke:
ttlPrc = 300
objPrc = free_object()
DIM Particles(ttlPrc) As Particle
`Make particles
for x=objPrc to objPrc+ttlPrc
make object plain x,10,10
`make object triangle x, -10, 0, 0, 0, 10, 0, 10, 0, 0
texture object x,img
hide object x
set object transparency x,3
ghost object on x,0
set object transparency x, 1
set alpha mapping on x, 100
next x
RETURN
loopSmoke:
`Loop through particles
for t=1 to ttlPrc
Particles(t).sz.x = Particles(t).sz.x + 0.5
Particles(t).sz.y = Particles(t).sz.y + 0.5
Particles(t).p.x = Particles(t).p.x + Particles(t).v.x + windx#
Particles(t).p.y = Particles(t).p.y + Particles(t).v.y
Particles(t).p.z = Particles(t).p.z + Particles(t).v.z + windz#
`Fade particle value
Particles(t).Fade = Particles(t).Fade - 1
`Position, scale and fade particle object
position object objPrc+t-1,Particles(t).p.x,Particles(t).p.y,Particles(t).p.z
scale object objPrc+t-1,Particles(t).sz.x,Particles(t).sz.y,100
fade object objPrc+t-1,Particles(t).Fade
`Point at camera
set object to camera orientation objPrc+t-1
next t
for i = 1 to ttlPrc
`if i>ttlPrc then i=1
if Particles(i).Fade < 0
`Position
Particles(i).p.x = 0
Particles(i).p.y = 0
Particles(i).p.z = 100
`Scale
Particles(i).sz.x = 50
Particles(i).sz.y = 50
`Velocity (randomize)
Particles(i).v.x = rnd(100)/1000.0-0.1
Particles(i).v.y = rnd(200)/1000.0+0.1
Particles(i).v.z = rnd(100)/1000.0-0.1
Particles(i).Fade = ttlPrc / 2.0
`Show the particle
show object objPrc+i-1
endif
next i
RETURN
Function free_object()
Repeat
Inc i
Until Object Exist(i) = 0
EndFunction i
Function free_image()
Repeat
Inc i
Until Image Exist(i) = 0
EndFunction i