Take a look at this example from forum user
Turoid.
`make a simple image
ink rgb(12,135,242),0
box 0,0,40,40
get image 1,0,0,40,40
`the main settings
sync on
sync rate 75
autocam off
`this is the player object
make object cube 1,15
position object 1,0,190,0
set object collision on 1
`add some graphics
fog on
fog distance 200
set ambient light 100
`make the ground
make object box 3,400,10,400
position object 3,0,-5,0
`check if an object exist, if not, create one and set the collision on it
for i = 1 to 100
`check
if object exist(i)=0
`make one
make object cube i,20
position object i,rnd(400)-200,rnd(20),rnd(400)-200
endif
`if it exists
if object exist(i)=1
`collision on it
set object collision on i
`graphics :P
texture object i,1
endif
next i
`global jump variables
global jumping
global start_y#
global jump_angle#
global jumpable
`main loop
do
`sync
sync
`move player
move_player_with_collision(1,0,yang#)
`get the camera angles
yang#=yang#+mousemovex()
xang#=xang#+mousemovey()
`get the player object position
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
`position and rotate the camera
position camera x#,y#,z#
yrotate camera yang#
xrotate camera xang#
`loop
loop
function move_player_with_collision(objectnr,coll,colang#)
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
objectang#=colang#
if keystate(17)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#,abs(sin(objectang#)))
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#)))
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
endif
if keystate(31)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+180,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+180,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
endif
if keystate(32)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+90,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+90,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
endif
if keystate(30)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+270,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+270,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
if jumping = 0
start_y# = y# - 2.0
if spacekey()=1 and jumpable = 1
jumping = 1
jump_angle# = 0
start_y# = object position y(objectnr)
jumpable = 0
endif
endif
if jumping = 1
jump_angle# = jump_angle# + 3
if jump_angle# => 180 then jumping=0
endif
position object objectnr,x#,start_y# + sin(jump_angle#)*20.0,z#
if object collision(objectnr,coll)>0
jumping = 0
jump_angle# = 0
position object objectnr,x#,yz#,z#
jumpable = 1
endif
endfunction
This is the best one I found for an FPS. At least I think it works very well, and it is simple to understand.
"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin