I come to you bringing an almost working fps code. It includes jumping, strafing and object collision. Buildings levels with this would be extremly easy. The only problem with this is that you can climb up walls by jumping and moving towards them. This provides obvious problems (jumping of level, climbing walls makes gameplay much harder, defeats the purpose of realistic gravity...)
The code is the engine for my fps, Arena, which is a hybrid of the sliding collision code tutorial and the idea of strafing. I have exlcuded the weapons and enemies to simplify it. Here is the code, can anyone tell me what I'm doing wrong to avoid jumping up the walls? Thanks in advance, you'll get a mention or two in the credits.
sync on
hide mouse
sync rate 60
make object box 1,10,150,1000 : position object 1,-500,0,0 : color object 1,rgb(0,40,20)
make object box 2,10,150,1000 : position object 2, 500,0,0 : color object 2,rgb(155,40,20)
make object box 3,1000,150,10 : position object 3, 0,0,-500 : color object 3,rgb(0,255,255)
make object box 4,1000,150,10 : position object 4, 0,0, 500 : color object 4,rgb(255,0,255)
make object box 5,1000,10,1000 : position object 5,0,-5,0 : color object 5,rgb(0,255,0)
set object collision on 5
set object collision on 4
set object collision on 3
set object collision on 2
set object collision on 1
create bitmap 1,32,32 : cls rgb(0,155,0) : ink rgb(0,145,0),0 : box 4,4,12,12
get image 1,0,0,32,32 : delete bitmap 1 : texture object 5,1
scale object texture 5,200,200
REM MAKE CHARACTER
make object cylinder 11,1
hide object 11
set object collision on 11
position object 11,0,0,0
color object 11,rgb(20,100,255)
make object collision box 11,-4,-4,-4,4,4,4,0
disable object zdepth 11
rem Make a pedestal steps
for t=0 to 4
make object box 6+t,50,8,50
position object 6+t,0,4+(t*10),100+(t*50)
color object 6+t,rgb(100,200,100)
set object collision on 6+t
next t
for t=6 to 10
set object collision on t
make object collision box t,-25,-4,-25,25,4,25,0
next t
make object collision box 1,-6,-75,-500,5,75,500,0
make object collision box 2,-6,-75,-500,5,75,500,0
make object collision box 3,-500,-75,-6,500,75,5,0
make object collision box 4,-500,-75,-6,500,75,5,0
make object collision box 5,-500,-50,-500,500,6,500,0
playergrav#=2
REM **************************************************************************
REM ::::::::::::::::::---START LOOP---::::::::::::::::::::::::::::::::::::::::
REM **************************************************************************
DO
oldcAY#=cAY#
oldcAX#=cAX#
oldposx#=object position x(11)
oldposy#=object position y(11)
oldposz#=object position z(11)
cAY#=WrapValue(cAY#+MousemoveX()*.15)
cAX#=WrapValue(cAX#+MousemoveY()*.15)
caZ#=Camera angle Z()
yrotate object 11,cAY#
If keystate(18)
posx#=Newxvalue(posx#,cAY#,2)
posz#=Newzvalue(posz#,cAY#,2)
Endif
If keystate(32)
posx#=Newxvalue(posx#,Wrapvalue(cAY#-180),2)
posz#=Newzvalue(posz#,Wrapvalue(cAY#-180),2)
Endif
If keystate(31)
posx#=Newxvalue(posx#,Wrapvalue(cAY#-90),2)
posz#=Newzvalue(posz#,Wrapvalue(cAY#-90),2)
Endif
If keystate(33)
posx#=Newxvalue(posx#,Wrapvalue(cAY#+90),2)
posz#=Newzvalue(posz#,Wrapvalue(cAY#+90),2)
Endif
REM PICK CURRENT GUN
if scancode()=2 THEN cgun#=1
if scancode()=3 THEN cgun#=2
if scancode()=4 THEN cgun#=3
if scancode()=5 THEN cgun#=4
if scancode()=6 THEN cgun#=5
if scancode()=7 THEN cgun#=6
if keystate(17) and nw#=0
nw#=1
inc cgun#
if cgun#=7 then cgun#=1
endif
if keystate(17)=0 then nw#=0
set cursor 0,0
print cgun#
REM CHARACTER COLLISION
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0
endif
if spacekey()=1 and playergrav#=0 then playergrav#=2
playergrav#=playergrav#-.1
posy#=posy#+playergrav#
REM CHARACTER COLLISION
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0
endif
cTestX#=WrapValue(cAX#-180)
if cTestX#>225 then cAX#=45
if cTestX#