Scribbla said i should post this, as it may help people, so here it is:
"turn_smoothing" determines how smooth the turning is.
"tolerance" determines the dead spot in the centre of the controller. Higher values result in a bigger dead spot.
"turn_smoothing" determines how smooth the turning is.
"tolerance" determines the dead spot in the centre of the controller. Higher values result in a bigger dead spot.
; Using an analogue Controller ; left stick by Ross c Graphics3D 1024,768,32 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,4,-40 light=CreateLight() cube=CreateCube( ) PositionEntity cube,0,0,3 cone=CreateCone( ) PositionEntity cone,0,0,5 RotateEntity cone,90,0,0 EntityParent cone,cube Global Joy_X# Global Joy_Y# Global tolerance# = 0.7 Global yaw_goto# Global yaw# Global turn_smoothing# = 0.8 While Not KeyHit(1) ; start main loop esc for Quit If JoyX#() > -tolerance And JoyX#() < tolerance And JoyY#() > -tolerance And JoyY#() < tolerance Then Joy_Y# = 0 Joy_X# = 0 Else Joy_X# = JoyX#() Joy_Y# = JoyY#() yaw_goto = ATan2( -JoyX#(), -JoyY#() ) If yaw_goto - yaw > 180 Then If yaw < 0 Then yaw = yaw + 360 End If ElseIf yaw_goto - yaw < -180 Then If yaw > 0 Then yaw = yaw - 360 End If End If yaw = yaw_goto - ((yaw_goto - yaw)*turn_smoothing) End If speed# = Sqr(Joy_Y#*Joy_Y#+ Joy_X#*Joy_X#)/2 MoveEntity cube,0,0,speed# RotateEntity cube, 0,yaw#,0; EntityRoll(cube) RenderWorld Text 10,10,"JoyX()"+" "+JoyX()+" "+"joy_x= "+joy_x Text 10,30,"JoyY()"+" "+JoyY()+" "+"joy_y= "+joy_y Text 10,40,"yaw = "+yaw Flip Wend ; end main loop End ; end program