The commands essentially return the distance travelled by the Mouse pointer (I'm pretty sure in Pixels) since it was last callled. Since it only returns the distance since it was last called, it reflects the average speed (pixels/frame) the pointer has moved, and will be 0 if the pointer hasn't moved since it was last called.
Finally, movement to the left or upwards is negative (for X and Y respectively)
This little code should help show how they work:
Graphics 800,600,32,6
SetBuffer BackBuffer()
ShowPointer() ; Not needed really, but here for completeness
MoveMouse 400,300
While Not KeyDown(1)
Cls
If (GetMouse()=1) Then MoveMouse 400,300
X=MouseXSpeed()
Y=MouseYSpeed()
Text 0,0,"X="
Text 20,0,Str(X)
Text 60,0,"Y="
Text 80,0,Str(Y)
Flip
Wend
As for the problem with the camera revolving around the car, I recommend parenting the camera to a Pivot which is then parented to the car.
Use the mouse functions to turn the pivot, and keep the camera Pointed at the pivot. This way, as the pivot roptates, the camera will revolve around the car. Here's an example:
Graphics3D 800,600,32,6
SetBuffer BackBuffer()
Global CAR_SPEED#=0.5
Global CAM_TURN_SPEED#=0.1
; Set up a scene
AmbientLight 160,160,192
Global Sun=CreateLight()
Global Ground=CreatePlane(16)
EntityColor Ground,64,128,32
Dim Trees(101)
Local IterTree%
For IterTree= 0 To 100
Trees(IterTree)=CreateCone(3)
EntityColor Trees(IterTree),Rand(0,64),Rand(160,240),Rand(0,8)
PositionEntity Trees(IterTree),Rand(0-CAR_SPEED*30,CAR_SPEED*30),0,Rand(20,100)
Next
Global Car=CreateCube()
EntityColor Car,160,32,32
EntityShininess Car,0.4
Global CameraPivot=CreatePivot(Car) ;Pivot Parented to Car
Global Cam=CreateCamera(CameraPivot) ;Camera Parented to Pivot
CameraClsColor Cam,32,16,240
MoveEntity Cam,0,1,-10 ; Put some distance between the Camera and its Pivot (and therefore the Car too)
While Not KeyDown(1)
MoveEntity Car,0,0,CAR_SPEED ;vroooooooooooom!
;Get the Mouse Speed
Local X%=MouseXSpeed()
Local Y%=MouseYSpeed()
Local Z%=MouseZSpeed()
; Use the Mouse Speed values to rotate Pivot
TurnEntity CameraPivot,Y*CAM_TURN_SPEED,X*CAM_TURN_SPEED,0 ;Horizontal Mouse turns YAW, Vertical Mouse turns PITCH
;Keep the camera aligned to the Pivot (and therefore to the Car)
PointEntity Cam,CameraPivot
; MouseZSpeed() refers to the MouseWheel - we can use that to Zoom in/out
MoveEntity Cam,0,0,Z*CAM_TURN_SPEED*5
;Recycle Trees (ecologically concious!)
For IterTree=0 To 100
If (EntityDistance(Trees(iterTree),Cam)>20) And (Not(EntityInView(Trees(IterTree),Cam)))
PositionEntity Trees(IterTree),Rand(0-CAR_SPEED*30,CAR_SPEED*30)+EntityX(Car,1),0,EntityZ(Car,1)+Rand(20,100)
End If
Next
UpdateWorld()
RenderWorld()
Flip
Wend
|