; JoyRoll Example ; --------------- Graphics 640,480,0,2 SetBuffer BackBuffer() While Not KeyDown(1) Cls ; JoyRoll returns the stick's rotation-z axis scaled to ; degrees, from -180.0 to 180.0. On many flight sticks the ; twist grip reports here - the wings bank left/right. roll#=JoyRoll() If JoyType()=0 Then Text 0,0,"Esc: exit" Text 0,60,"No joystick detected - plug in a flight stick to try this example." Text 0,80,"With one attached, the wings below bank with the twist axis." Else Text 0,0,"Twist the stick (roll axis) Esc: exit" End If ; Cockpit view: a fixed horizon and a banking wing bar cx=320 cy=280 Color 90,90,90 Line cx-160,cy,cx+160,cy ; the horizon line Text cx+170,cy-6,"horizon" ; The wing bar banks clockwise as roll goes positive Color 255,220,0 Line cx-Cos(roll)*80,cy-Sin(roll)*80,cx+Cos(roll)*80,cy+Sin(roll)*80 Oval cx-6,cy-6,12,12,False ; the cockpit marker Color 255,255,255 Text 0,20,"JoyRoll() = "+roll+" degrees" Text 0,40,"(JoyPitch() = "+JoyPitch()+" JoyYaw() = "+JoyYaw()+")" Flip Wend End