this is a small fps ive been working on to teach myself db
(mainly bits of other tuts).
i was wondering if anyone can fix the problem with my lmb automatic weapon it shoots fine but when its used the 20 bullets it doesnt reuse them like it should.
also if anyone would see if there are better ways to do some of the codeing or the ordering of the program
thanks
trav
`misc
set display mode 640,480,16
fog on
hide mouse
sync on
sync rate 30
`loading - setting up
load bitmap "rock1.bmp",1
get image 1,0,0,256,256
delete bitmap 1
Load Image "flame1.bmp",2
rem varibles
rem Set up bullets
dim shot#(20,10)
dim bulletlife(20)
bulletcount = 0
pn=10
`object creation
`base
make object cube 1,5
`barrel
Make object cylinder 2,2
XRotate Object 2,90
Fix object pivot 2
Scale object 2,100,100,500
position object 2,0,-7,15
Lock object on 2
`rkt
Make Object Sphere 50,2
Hide Object 50
`exp1
Make Object Sphere 30,20
texture object 30,2
ghost object on 30
Hide Object 30
`exp2
Make Object Sphere 31,20
texture object 31,2
ghost object on 31
Hide Object 31
`rkttrail
For x = 0 to 10
Make object sphere x+10,5
XRotate Object x+10,90
Fix object pivot x+10
Texture object x+10,2
Set object x+10,1,0,0
Ghost object on x+10
Next x
`bullets
for i=100 to 120
make object sphere i,1
next i
`matrix smothing
gosub maxsmooth
Update Matrix MATNUM
`***main***
DO
`kybrd cntrls
if keystate(30)=1
sx = Newxvalue(sx,wrapvalue(ax-90),15)
sz = Newzvalue(sz,wrapvalue(ax-90),15)
endif
if keystate(32)=1
sx = Newxvalue(sx,Wrapvalue(cy+90),15)
sz = Newzvalue(sz,Wrapvalue(cy+90),15)
endif
if keystate(17)=1
sx = Newxvalue(sx,Wrapvalue(cy+0),15)
sz = Newzvalue(sz,Wrapvalue(cy+0),15)
endif
if keystate(31)=1
sx = Newxvalue(sx,Wrapvalue(cy+180),15)
sz = Newzvalue(sz,Wrapvalue(cy+180),15)
endif
`misc
position mouse 320,240
circle 320,294,20
circle 320,247,10
circle 320,247,2
`collision
if by 0 then shotrecently#=shotrecently#-1
for i=100 to 120
if shot#(i,0)=1
shot#(i-100,1)=shot#(i-100,1)+shot#(i-100,4)
shot#(i-100,2)=shot#(i-100,2)+shot#(i-100,5)
shot#(i-100,3)=shot#(i-100,3)+shot#(i-100,6)
position object i,shot#(i-100,1),shot#(i-100,2),shot#(i-100,3)
shot#(i-100,9)=shot#(i-100,9)-1
if shot#(i-100,9)=0
hide object i
shot#(i-100,0)=0
endif
endif
next i
`rocket
if Mouseclick()=2 and explode = 0 and rl = 0
echk = 0
Position object 50,cpx,cpy,cpz
Set object to camera orientation 50
rL=50
Show object 50
Endif
`The particle system
if rl>0
Dec rL
Move object 50,10
inc Pn
if Pn=20 then Pn=10
show object pn
Scale object Pn,100,100,100
Position object Pn,bX,bY,bz
rotate object Pn,cX,cY,cZ
zrotate object Pn,rnd(360)
for px = 1 to 10
scale object int((Wrapvalue((Pn-9+px)*36))/36)+10,100+px*25,100+px*25,100+px*25
set cursor 10,10
next px
endif
if rL = 0
if echk = 0 then explode = 20 : echk = 1
for x=10 to 20
hide object x
next x
hide object 50
endif
If Explode > 0 then Gosub ExplodeRocket
`positioning
rotate object 1,ax,cy,cz
position object 1,sx,my,sz
position camera ox,oy+30,oz
rotate camera cx,cy,cz
`setting values
ox=object position x(1)
oy=object position y(1)
oz=object position z(1)
ax=object angle x(1)
my=get ground height(1,ox,oz)
cpx=camera position x()
cpy=camera position y()
cpz=camera position z()
cx=wrapvalue(cx+mousemovey())
cy=wrapvalue(cy+mousemovex())
cz=camera angle z()
gx=object position x(2)
gy=object position y(2)
gz=object position z(2)
bx=object position x(50)
by=object position y(50)
bz=object position z(50)
SYNC
LOOP
`sub-progs
ExplodeRocket:
Position object 30,bX,bY,bZ
Show object 30
Position object 31,bX,bY,bZ
Show object 31
EScale=20*(30-Explode)
Scale object 30,EScale,EScale,EScale
Yrotate object 30,WrapValue(Explode*37)
Scale object 31,EScale/1.5,EScale/1.5,EScale/1.5
Yrotate object 31,WrapValue(359-Explode*37)
Dec Explode
If Explode = 0 then hide object 30: Hide object 31
Return
maxsmooth:
XSEG = 60
ZSEG = 60
WIDTH# = 4000.0
LENGTH# = 4000.0
MATNUM = 1
MAX_HEIGHT = 250
Make Matrix MATNUM, WIDTH#, LENGTH#, XSEG, ZSEG
`textureing
prepare matrix texture 1,1,1,1
fill matrix 1,0.0,1
update matrix 1
For X = 1 To XSEG -1
For Z = 1 To ZSEG -1
Set Matrix Height MATNUM, X, Z, Rnd(MAX_HEIGHT*2) - MAX_HEIGHT
Next Z
Next X
Dim Mat#(XSEG,ZSEG)
PASSES = 4
For I = 1 To PASSES
For X = 0 To XSEG
For Z = 0 To ZSEG
Mat#(X,Z) = Get Matrix Height(MATNUM, X, Z)
Next Z
Next X
For X = 1 To XSEG - 1
For Z = 1 To ZSEG - 1
CURRENT# = Mat#(X,Z)
TOPLEFT# = Mat#(X-1,Z+1)
TOP# = Mat#(X,Z+1)
TOPRIGHT# = Mat#(X+1,Z+1)
RIGHT# = Mat#(X+1,Z)
BOTTOMRIGHT# = Mat#(X+1,Z-1)
BOTTOM# = Mat#(X,Z-1)
BOTTOMLEFT# = Mat#(X-1,Z-1)
LEFT# = Mat#(X-1,Z)
TOTAL# = CURRENT# + TOPLEFT# + TOP# + TOPRIGHT# + RIGHT# + BOTTOMRIGHT# + BOTTOM# + BOTTOMLEFT# + LEFT#
AVERAGE# = TOTAL# / 9
Set Matrix Height MATNUM, X, Z, AVERAGE#
Next Z
Next X
Next I
return