Posted: 14th Oct 2006 10:27
Hello everyone,
I cant quite seem to get this camera situated the way I would like to. Whenever I move the mouse left or right I want the object to stay in the middle of the screen. Any help will be appreciated.
Thank you[ Sync On
Sync Rate 0
Hide mouse
Backdrop on
Set camera range 1,5000
Fog on
Fog distance 4000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)
make object cube 1 ,75
Rem make matrix
Make matrix 1,10000,10000,20,20
Rem texture matrix
rem Randomize the matrix
randomize matrix 1,125
X#=5000
Z#=5000
Rem Main loop
Do
OldCamAngleY# = Camera Angle Y()
OldCamAngleX# = Camera Angle X()
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
rem Control camera with arrow keys
if upkey()=1 then x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10)
if downkey()=1 then x#=newxvalue(x#,a#,-10) : z#=newzvalue(z#,a#,-10)
if leftkey()=1 then x#=newzvalue(x#,a#,-10) : z#=newxvalue(z#,a#,-10)
if rightkey() = 1 then x#=newzvalue(x#,a#,10) : z#=newxvalue(z#,a#,10)
rem if leftkey()=1 then a#=wrapvalue(a#-10.0)
rem if rightkey()=1 then a#=wrapvalue(a#+10.0)
rem Update character
y#=get ground height(1,x#,z#)+50.0
position object 1,x#,y#,z#
yrotate object 1,a#
rem Position camera to the back of the character
cx#=newxvalue(x#,wrapvalue(a#+180),300)
cz#=newzvalue(z#,wrapvalue(a#+180),300)
cy#=get ground height(1,cx#,cz#)+100.0
position camera cx#,cy#,cz#
rem Point camera at object
point camera x#,y#,z#
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
yrotate object 1, WrapValue(CameraAngleY#+MousemoveX()*0.2)
rem Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
rem Y# = Get ground height(1,X#,Z#) + 50
rem Position Camera X#,Y#+50,Z#
Rem Refresh Screen
Sync
code]