Hey! I have been working on the 3-D Monster Hunt tutorial, and I have been coming along quite well with it. Only problem I have come across lately is that I have added smoke particles to the bullet I shoot. Now, when I had the bullet and patricle code in the main loop, it was no problem. But now that I have made it into a GOSUB, you can only see the smoke particles on the first bullet! Here is the code:
sync on
sync rate 30
backdrop on
hide mouse
load 3dsound "Large explosion 2.wav",2
set sound volume 2, 100
set camera range 1,5000
fog on
fog distance 4000
fog color rgb(128,128,128)
color backdrop rgb(128,128,128)
make matrix 1,10000,10000,20,20
load image "rustyIron.bmp",1
prepare matrix texture 1,1,1,1
fill matrix 1,0,1
randomize matrix 1,125
load object "L-Alien Mutant-Idle.x",4
scale object 4,5000,5000,5000
loop object 4
position object 4,4500,get ground height (1,4500,4500),4500
set object collision to boxes 4
autocam off
position camera 4999,4999,4999
X# = 4999
Y# = 4999
Z# = 4999
rem make gun
make object cylinder 30,2
xrotate object 30,90
fix object pivot 30
scale object 30,100,100,500
position object 30,0,-7,15
lock object on 30
rem make bullets
make object sphere 2,2
hide object 2
set object collision to spheres 2
load sound "music triumph loop.wav",1
loop sound 1
rem load particles
load image "Cement_render.bmp",2
for x = 0 to 10
make object plain x+10,5,5
texture object x+10,2
set object x+10,1,0,0
ghost object on x+10
next x
rem initialize particle counter
pn = 10
do
set cursor 0,0
print screen fps()
print X#
print Y#
print Z#
oldcamangleY# = camangleY#
oldcamangleX# = camangleX#
camangleY# = wrapvalue(camangleY#+mousemoveX()*0.2)
camangleX# = wrapvalue(camangleX#+mousemoveY()*0.2)
if upkey()=1
xtest#=newxvalue(x#,camangleY#,20)
ztest#=newzvalue(z#,camangleY#,20)
if xtest#>=0 and xtest<=10000 and ztest#>=0 and ztest#<=10000
X#=xtest#
Z#=ztest#
endif
endif
if downkey()=1
xtest#=newxvalue(X#,wrapvalue(camangleY#-180),10)
ztest#=newzvalue(Z#,wrapvalue(camangleY#-180),10)
if xtest#>=0 and xtest<=10000 and ztest#>=0 and ztest#<=10000
X# = xtest#
Z# = ztest#
endif
endif
rem Here is where I added the strifing
if leftkey()=1
xtest#=newxvalue(X#,WrapValue(camangleY#-90),10)
ztest#=newzvalue(Z#,wrapvalue(camangleY#-90),10)
if xtest#>=0 and xtest#<=10000 and ztest#>=0 and ztest#<=10000
X# = xtest#
Z# = ztest#
endif
endif
rem more strifing here
if rightkey()=1
xtest#=newxvalue(X#,wrapvalue(camangleY#+90),10)
ztest#=newzvalue(Z#,wrapvalue(camangleY#+90),10)
if xtest#>=0 and xtest#<=10000 and ztest#>=0 and ztest#<=10000
X# = xtest#
Z# = ztest#
endif
endif
position listener X#,Y#+50,Z#
rotate listener 0,camangleY#,0
if mouseclick()=1 and bulletlife = 0
position object 2,X#,Y#+43,Z#
set object to camera orientation 2
Bulletlife = 25
show object 2
loop sound 2
endif
if bulletlife>0 then gosub ShootBullet
if camangleX#>270
if camangleX# - 270 > 90 then camangleX# = 270
else
if camangleX# > 90 and camangleX#-270 < 270 then camangleX# = 90
endif
Yrotate camera curveangle(camangleY#,oldcamangleY#,24)
Xrotate camera curveAngle(camangleX#,oldcamangleX#,24)
y# = get ground height(1,X#,Z#)
position camera X#,Y#+50,Z#
sync
loop
ShootBullet:
Dec bulletlife
move object 2,20
if object collision(4,2) then stop sound 1
bX# = object position x(2)
bY# = object position y(2)
bZ# = object position z(2)
rem patricles
inc pn
if pn>20 then pn=10
scale object pn,100,100,100
position object pn,bX#,bY#,bZ#
point object pn,bX#,bY#,bZ#
Zrotate object pn,rnd(180)
for x = 1 to 10
scale object int((Wrapvalue((Pn-9+x)*36))/36)+10,100+x*25,100+x*25,100+x*25
set cursor 10,10
print int((wrapvalue(pn+x)*36))/36+10
next x
position sound 2,bX#,bY#,bZ#
if bulletlife = 0
hide object 2
stop sound 2
for x = 10 to 20
hide object x
next x
explode = 20
endif
return
I changed a few things to it, like how I used DB collision detection instead of the math collision engine the tut used. Also, so I could be sure of when the collision detected a hit on the monster, I set it so the background music would go off. Thansk for any help!
--I know this must be something very simple, but for some reason, I can't put my finger on it! Thanks!
Fraggles where quite the scary lot...