Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Thirdperson Mousemove()

Author
Message
smhillis
19
Years of Service
User Offline
Joined: 10th Oct 2006
Location:
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]
luke810
19
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 18th Oct 2006 15:46
If you want the camera to rotate around a point you need to use sin and cos operations. If you dont want to do that then you have to use the camera follow commands and use an object for movement and let the camera follow it.

load the zip file and there is a small game demo that uses a combination of both of these. It gives for a cool affect.
Gamer Making
19
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 24th Oct 2006 03:06
Cool luke ill try breaking the code maybe sometime.

Bach Tran

Login to post a reply

Server time is: 2026-07-08 14:10:52
Your offset time is: 2026-07-08 14:10:52