What the title says
. WASD, mouse to control player, LMB to shoot, frames per sec in the corner.
`Smoke particles with rocket launcher
`By Hamish McHaggis
`30/9/03
#CONSTANT NUMPARTICLES 50
type XYZType
X as float
Y as float
Z as float
endtype
type particleType
position as XYZType
scale as XYZType
rotation as XYZType
rotationSpd as XYZType
fade as float
endtype
dim smoke(NUMPARTICLES) as particleType
dim fire(NUMFIREPARTICLES) as particleType
playerSpeed#=1
`Setup
sync on
sync rate 0
hide mouse
backdrop on
color backdrop rgb(100,100,255)
`Make the smoke image
create bitmap 1,100,100
set current bitmap 1
for x=1 to 1000
colour=rnd(50)+50 :`Random transparency
ang=rnd(360) :`Random angle
rad=rnd(12)+rnd(10) :`Random radius
ink rgb(colour,colour,colour),0
box 25+sin(ang)*rad,25+cos(ang)*rad,26+sin(ang)*rad,26+cos(ang)*rad :`Draw speck
next x
blur bitmap 1,3
get image 1,0,0,50,50
delete bitmap 1
`Make particles
for x=100 to NUMPARTICLES+100
make object plain x,15,15
texture object x,1
set object transparency x,1 :`Make transparent
ghost object on x :`Ghost object so it can fade out of view
hide object x
set object rotation xyz x
`Make so that it is not affected by ambient light, rem this out and you'll see the difference
set object ambient x,0
next x
`Make shell object
make object sphere 1,2
color object 1,rgb(0,0,0)
hide object 1
`Create player object and attach gun to it as a limb
make object cube 3,1
hide object 3
make mesh from object 1,3
add limb 3,1,1
offset limb 3,1,2,1.5,7
make object cylinder 2,2
scale object 2,100,600,100
xrotate object 2,90
fix object pivot 2
glue object to limb 2,3,1
`Make the grass image
create bitmap 1,256,256
set current bitmap 1
ink rgb(0,100,0),0
box 0,0,256,256
for x=1 to 100000
colour=rnd(60)+50 :`Random colour
ink rgb(0,colour,0),0
dot rnd(256),rnd(256) :`Draw speck
if x=50000 then blur bitmap 1,4
next x
blur bitmap 1,2
get image 2,0,0,256,256
delete bitmap 1
`Create matrix
make matrix 1,400,400,10,10
randomize matrix 1,20
prepare matrix texture 1,2,2,2
update matrix 1
do
`Control player with wasd
if lower$(inkey$())="w"
playerX#=newxvalue(playerX#,playerA#,playerSpeed#)
playerZ#=newzvalue(playerZ#,playerA#,playerSpeed#)
endif
if lower$(inkey$())="s"
playerX#=newxvalue(playerX#,playerA#,-playerSpeed#)
playerZ#=newzvalue(playerZ#,playerA#,-playerSpeed#)
endif
if lower$(inkey$())="a"
playerX#=newxvalue(playerX#,wrapvalue(playerA#-90),playerSpeed#)
playerZ#=newzvalue(playerZ#,wrapvalue(playerA#-90),playerSpeed#)
endif
if lower$(inkey$())="d"
playerX#=newxvalue(playerX#,wrapvalue(playerA#+90),playerSpeed#)
playerZ#=newzvalue(playerZ#,wrapvalue(playerA#+90),playerSpeed#)
endif
`Put player on matrix
playerY#=get ground height(1,playerX#,playerZ#)+20
`Mouselook
playerA#=wrapvalue(playerA#+mousemovex()/2)
playerLook#=wrapvalue(playerLook#+mousemovey()/3)
`Position player object
position object 3,playerX#,playerY#,playerZ#
rotate object 3,playerLook#,playerA#,0
`Position camera
rotate camera playerLook#,playerA#,0
position camera playerX#,playerY#,playerZ#
`Control firing of gun
if mouseclick()=1 and fire=0
fire=1
gunRecoil=1
gunRecoilZ#=7
camX#=camera position x()+sin(playerLook#)*sin(playerA#)*1.5+cos(playerA#)*2+sin(playerA#)*cos(playerLook#)*8
camY#=camera position y()+cos(playerLook#)*1.5-sin(playerLook#)*8
camZ#=camera position z()+sin(playerLook#)*cos(playerA#)*1.5+sin(wrapvalue(360-playerA#))*2+cos(playerA#)*cos(playerLook#)*8
position object 1,camX#,camY#,camZ#
set object to camera orientation 1
show object 1
endif
`If bullet is in the air...
if fire=1
`Move bullet
move object 1,6
inc fireDist
`Stop bullet after a while
if fireDist=200
fire=0
fireDist=0
hide object 1
endif
inc smokeSwitch
if smokeSwitch>2 then smokeSwitch=0
`Deploy particle every nth loop
if smokeSwitch=0
`Increase particle number and loop round if needed
inc smokeCount
if smokeCount>NUMPARTICLES then smokeCount=1
`Position particle
smoke(smokeCount).position.X=object position x(1)
smoke(smokeCount).position.Y=object position y(1)
smoke(smokeCount).position.Z=object position z(1)
`Set particle original stats
smoke(smokeCount).fade=100
smoke(smokeCount).scale.X=100+rnd(50)
smoke(smokeCount).scale.Y=100+rnd(50)
smoke(smokeCount).rotationSpd.Z=rnd(40)/20.0-1
smoke(x).rotation.Z=rnd(180)
`Position, rotate and show particle
position object smokeCount+99,smoke(smokeCount).position.X,smoke(smokeCount).position.Y,smoke(smokeCount).position.Z
zrotate object smokeCount+99,rnd(180)
show object smokeCount+99
endif
`See if shell is lower than the ground and stop it if it is
if smoke(smokeCount).position.Y<=get ground height(1,object position x(1),object position z(1))
fire=0
fireDist=0
hide object 1
endif
endif
`Update paricles (fade, scale, position and rotate them)
for x=1 to NUMPARTICLES
`If particle isn't completely faded
if object visible(x+99)=1
dec smoke(x).fade,0.5
inc smoke(x).scale.X,4
inc smoke(x).scale.Y,3
dec smoke(x).position.X,0.2
inc smoke(x).position.Y,0.02
inc smoke(x).position.Z,0.04
inc smoke(x).rotation.Z,smoke(x).rotationSpd.Z
`If the particle is completely faded, hide it
if smoke(x).fade<0 then hide object x+99
fade object x+99,smoke(x).fade
scale object x+99,smoke(x).scale.X,smoke(x).scale.Y,100
position object x+99,smoke(x).position.X,smoke(x).position.Y,smoke(x).position.Z
set object to camera orientation x+99 :`Point particle towards camera always
roll object right x+99,smoke(x).rotation.Z
endif
next x
`Control gun recoil
if gunRecoil>0
`Backwards recoil
if gunRecoil=1
gunRecoilZ#=curvevalue(-10,gunRecoilZ#,10)
gunRecoilRot#=gunRecoilZ#-7
if gunRecoilZ#<3
gunRecoil=2
endif
else
`Forwards recoil
gunRecoilZ#=curvevalue(8,gunRecoilZ#,20)
gunRecoilRot#=gunRecoilZ#-7
if gunRecoilZ#>7
gunRecoil=0
gunRecoilZ#=7
gunRecoilRot#=gunRecoilZ#-7
endif
endif
`Position gun limb
offset limb 3,1,2-(gunRecoilZ#-7)/5,1.5,gunRecoilZ#
rotate limb 3,1,gunRecoilRot#,0,0
endif
text 0,0,str$(screen fps())
sync
loop
Brains are for idiots.
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM