can anyone tell me what is wrong with this code?
Function move_player()
playerx# = 0
playery# = 0
turn# = 0
If KeyDown(17) = True
playerx# = playerx# + .3
Else If KeyDown(31) = True
playerx# = playerx# - .3
EndIf
If KeyDown(30) = True Then
playery# = -.3
Else If KeyDown(32) = True Then
playery# = .3
EndIf
turn# = MouseXSpeed()
TurnEntity player,0,-turn#,0
MoveEntity player,playery#,0,playerx#
End Function
it is meant to be the start of a movment engine i am playing with, but the turning via the mouse doesnt work. It works fine as long as you turn clockwise, but when you turn counter-clockwise, it will only turn as far as the original position it started (ie: 0 degrees) and wont turn any further. i have tried adding the lines:
If turn# < 0 Then turn# = (360 - turn#)
If turn# > 360 Then turn# = (turn# - 360)
but that doesnt seem to help either. Can anyone help? If you want me to post the main code as well, i will. thanks
~V~
Function move_player()
playerx# = 0
playery# = 0
turn# = 0
If KeyDown(17) = True
playerx# = playerx# + .3
Else If KeyDown(31) = True
playerx# = playerx# - .3
EndIf
If KeyDown(30) = True Then
playery# = -.3
Else If KeyDown(32) = True Then
playery# = .3
EndIf
turn# = MouseXSpeed()
TurnEntity player,0,-turn#,0
MoveEntity player,playery#,0,playerx#
End Function
it is meant to be the start of a movment engine i am playing with, but the turning via the mouse doesnt work. It works fine as long as you turn clockwise, but when you turn counter-clockwise, it will only turn as far as the original position it started (ie: 0 degrees) and wont turn any further. i have tried adding the lines:
If turn# < 0 Then turn# = (360 - turn#)
If turn# > 360 Then turn# = (turn# - 360)
but that doesnt seem to help either. Can anyone help? If you want me to post the main code as well, i will. thanks
~V~