to control looking up and down (linited to 69o in both dirctions:
pitch#=pitch#+mousemovey()
if pitch#>70 then pitch#=69
if pitch#<-70 then pitch#=-69
xrotate camera pitch#
to control turning:
turn#=turn#+mousemovex()
yrotate camera turn#
to move forwards (aims cmera up slightly from horizontal to allow for going up stairs/slopes then repositions to origional):
rem in loop
if upkey()=1 then move_camera_forwards(0.03)
rem after loop
function move_camera_forwards(move_speed#)
xcam#=camera angle x()
xrotate camera (185)
move camera 0, -(move_speed#)
xrotate camera 0,xcam#
endfunction
to move camera backwards (same idea as forwards):
rem in loop
if downkey()=1 then move_camera_backwards(0.03)
rem after loop
function move_camera_backwards(move_speed#)
xcam#=camera angle x()
xrotate camera (175)
move camera 0,move_speed#
xrotate camera xcam#
endfunction
to strafe left (also similar to forwards/backwards):
rem in loop
if leftkey()=1 then strafe_camera_left(0.03)
rem after loop
function strafe_camera_left(strafeleftpeed#)
yrotate camera (camera angle y(0)+90)
xcam#=camera angle x(0)
xrotate camera (185)
move camera strafeleftspeed#
xrotate camera xcam#
yrotate camera (camera angle y(0)-90)
endfunction
to strafe right (also same idea as aove):
rem in loop
if rightkey()=1 then strafe_camera_right(0.03)
rem after loop
function strafe_camera_right(straferightspeed#)
yrotate camera (camera angle y(0)-90)
xcam#=camera angle x(0)
xrotate camera (185)
move camera straferightspeed#
xrotate camera xcam#
yrotate camera (camera angle y(0)+90)
endfunction
gravity: (this is a bit trickier)
rem this must go at end of loop as so:
oldy#=camera position y()
gravity()
sync
rem if you want it elsewhere in your loop or are using collision
rem other than bsp then run collision here
newy#=camera position y()
if oldy#-newy#<0.02 and oldy#-newy#>-0.02 then hitground=1
if oldy#-newy#>=0.02 or oldy#-newy#<=-0.2 then hitground=0
loop
rem after loop
function gravity()
if hitground=0 then accel#=accel#+0.01
if hitground=1 then accel#=0
position camera camera position x(), camera position y()-(0.03+accel#), camera position z()
endfunction
http://www.larinar.tk
AMD athlon thoroughbred 2200, 512Mb ram, 40Gb HD, ati saphire radeon 9600 atlantis w/128mb ddr ram, good creative-labs soundcard, cd-rw + dvd drives.