I'm making an fps at the moment and have encountered an issue. I have mouselook working, but as a result the character flies in the direction the mouse is looking. I have been advised to use translateEntity, but this merely moves the player along the global x/z axis.
;game loop
While Not KeyHit(1)
A# = .5 ;movement speed
;mouselook
mxs# = mxs# + MouseXSpeed()
mys# = mys# + MouseYSpeed()
RotateEntity playerHull,mys#,-mxs,0
MoveMouse 100,100
If mxs# > 360 Then mxs# = 0 ;limits of y value of view
If mxs# < 0 Then mxs# = 360
If mys# > 80 Then mys# = 80 ;limits of x value of view
If mys# < -80 Then mys# = -80
;movement commands
If KeyDown(17) Then ;forward movement
MoveEntity playerHull,0,0,A#
walking=1
EndIf
If KeyDown(31) Then ;backwards movement
MoveEntity playerHull,0,0,-A#
walking=1
EndIf
If KeyDown(30) Then ;strafe left
MoveEntity playerHull,-A#,0,0
walking=1
EndIf
If KeyDown(32) Then ;strafe right
MoveEntity playerHull,A#,0,0
walking=1
EndIf
;viewbobbing
If walking=1
a1#=(a1#+shoe_size) Mod 360
Else
;a1#=a1#*0.8
EndIf
PositionEntity camera,Cos(a1#)*head_bang_X#,Sin(90+a1#*2)*head_bang_Y#,0,0
;footsteps
If Sin(90+a1*2)<-.85
If footstep_needed<>0
Color 255,255,255
PlaySound snd_step
footstep_needed=0
EndIf
Else
footstep_needed=1
EndIf
walking = 0;
UpdateWorld
RenderWorld
Text 10,575,"Movement Demo"
Flip
Wend
Can anyone recommend a solution to this?
|