Well, this has spawned some more goodness. Using the Polar_Object function, I've perfected my MouseLook routines!
RAWK! I've been waiting
so damn long to make a descent Mouselook.
I've also added
Mouse Smoothing, which is fun.
Check this out, for your #including pleasure:
FUNCTION MouseLook(Sensitivity#,WalkSpeed#,MouseSmoothing#)
` /me recommends:
` Sensitivity#=3.0
` WalkSpeed#=1.0 (to start)
` MouseSmoothing#=5.0 (Just to see the effect. 1.0 or less will turn in off)
HeadingX#=wrapvalue(HeadingX#+(mousemovex()/Sensitivity#))
HeadingZ#=wrapvalue(HeadingZ#+(mousemovey()/Sensitivity#))
`Forward
if KEYSTATE(17)=1
PolarMouseLookAdvance(CAMERA POSITION X(),CAMERA POSITION Y(),CAMERA POSITION Z(),HeadingZ#,HeadingX#,WalkSpeed#)
endif
`Backward
if KEYSTATE(31)=1
PolarMouseLookAdvance(CAMERA POSITION X(),CAMERA POSITION Y(),CAMERA POSITION Z(),HeadingZ#,HeadingX#,-1*(WalkSpeed#))
endif
`Strafe Left
if KEYSTATE(32)=1
PolarMouseLookStrafe(CAMERA POSITION X(),CAMERA POSITION Y(),CAMERA POSITION Z(),HeadingZ#,HeadingX#+90,WalkSpeed#)
endif
`Strafe Right
if KEYSTATE(30)=1
PolarMouseLookStrafe(CAMERA POSITION X(),CAMERA POSITION Y(),CAMERA POSITION Z(),HeadingZ#,HeadingX#-90,WalkSpeed#)
endif
`Rise
if mouseclick()=2
position camera CAMERA POSITION X(),CAMERA POSITION Y()+WalkSpeed#,CAMERA POSITION Z()
endif
`Fall
if KEYSTATE(57)=1
position camera CAMERA POSITION X(),CAMERA POSITION Y()-WalkSpeed#,CAMERA POSITION Z()
endif
if MouseSmoothing#>=1
hz#=CURVEANGLE(headingz#,CAMERA ANGLE x(), MouseSmoothing#)
hx#=CURVEANGLE(headingx#,CAMERA ANGLE y(), MouseSmoothing#)
ROTATE CAMERA hz#, hx#, 0
else
ROTATE CAMERA headingz#, headingx#, 0
endif
ENDFUNCTION
Function PolarMouseLookAdvance(posx#,posy#,posz#,anX#,anZ#,speed#)
rem Perform polar calculations using sin and cosine
new_x# = posx# + speed#*cos(anx#)*sin(anz#)
new_y# = posy# - speed#*sin(anx#)
new_z# = posz# + speed#*cos(anx#)*cos(anz#)
POSITION CAMERA new_x#,new_y#,new_z#
endfunction
Function PolarMouseLookStrafe(posx#,posy#,posz#,anX#,anZ#,speed#)
new_x# = posx# + speed#*sin(anz#)
new_y# = posy#
new_z# = posz# + speed#*cos(anz#)
POSITION CAMERA new_x#,new_y#,new_z#
endfunction
I'm sure this has been done before, but it has not come to my attention.
Cheers, again!
Now, for that space-buggie nose-dive...
ICQ: 92636554