In my Blitzbasic program as listed below, I put everything in for a simple walk around and look with mouse FPS. However, when I tried to make a crosshair that followed the mouse, I was unsuccessful for some unknown reason.
AppTitle "Colby's FPS"
Graphics3D 800,600,64,2
SetBuffer BackBuffer()
SeedRnd MilliSecs()
;HidePointer
;OBJECTS
Global crosshairs = LoadImage("crosshairs.bmp")
Global camera = CreateCamera()
Global cube = CreateCube()
Global light = CreateLight()
;OBJECT SPECS
MaskImage crosshairs,0,0,0
MidHandle crosshairs
PositionEntity camera,50,0,50
PositionEntity cube,50,0,45
PositionEntity light,0,10,0
;CALLED FUNCTIONS
While Not KeyHit(1)
;Cls
;Crosshair Follow
DrawImage crosshairs,20,20
;Camera Rotate
mxs# = mxs# + MouseXSpeed()
If mxs# > 360 Then mxs# = 0
If mxs# < 0 Then mxs# = 360
RotateEntity camera,0,-mxs#,0
RenderWorld()
UpdateWorld()
cameraCtrl()
Flip
Wend
End
;FUNCTIONS
Function cameraCtrl()
If KeyDown(208)
MoveEntity camera,0,0,-0.2
ElseIf KeyDown(200)
MoveEntity camera,0,0,0.2
ElseIf KeyDown(203)
MoveEntity camera,-0.2,0,0
ElseIf KeyDown(205)
MoveEntity camera,0.2,0,0
EndIf
If KeyDown(31)
MoveEntity camera,0,0,-0.2
ElseIf KeyDown(17)
MoveEntity camera,0,0,0.2
ElseIf KeyDown(30)
MoveEntity camera,-0.2,0,0
ElseIf KeyDown(32)
MoveEntity camera,0.2,0,0
EndIf
I think you mean centering the mouse as you rotate.
In this case, put this line before
RenderWorld()
: