0

在下面列出的 Blitzbasic 程序中,我将所有内容都放入了简单的四处走动并使用鼠标 FPS 进行查看。然而,当我试图制作一个跟随鼠标的十字准线时,由于某种未知原因我没有成功。

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
4

1 回答 1

0

我认为您的意思是在旋转时将鼠标居中。

在这种情况下,将此行放在前面RenderWorld()

...
MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2   <-----------
RenderWorld()
UpdateWorld()
...
于 2015-04-15T16:00:42.587 回答