Joystick and Space

Blitz3D Forums/Blitz3D Beginners Area/Joystick and Space

Have a variable which stores the amount to turn by each frame while the joystick is held in a certain direction. As long as the joystick is still held in that direction, increase the value of the variable (up to a maximum) if the joystick is held in a different direction then alter the variable. Something along the lines of this:


turnvar#=turnvar#+joyx()*somefloatingpointvalue ;(somefloatingpoint value would be set to a value which scales the joyx() value appropriately - try a few values)
if abs(turnvar#)>maxturnvar# then turnvar#=sgn(turnvar#)*maxturnvar#

;and to ensure it doesn't shoot off to positive/negative infinity and gradually settles back to zero:
turnvar#=turnvar#*0.9

turnentity yourship,0,turnvar,0




Note - I just edited to include the line turnvar=turnvar*0.9 for reason stated above