Joystick position: Difference between revisions

Joystick position en FreeBASIC
m (→‎{{header|Phix}}: nicer link text)
(Joystick position en FreeBASIC)
Line 692:
{{out}}
Result preview [https://ibb.co/tc0xH3q]
 
 
=={{header|FreeBASIC}}==
<lang freebasic>Screen 12
 
Dim As Single x, y
Dim As Integer buttons, result
 
Const JoystickID = 0
 
'This line checks to see if the joystick is ok.
If Getjoystick(JoystickID, buttons, x, y) Then
Print "Joystick doesn't exist or joystick error."
Print !"\nPress any key to continue."
Sleep
End
End If
 
Do
result = Getjoystick(JoystickID, buttons, x, y)
Locate 1,1
Print ; "result:"; result; " x:"; x; " y:"; y; " Buttons:"; buttons, "", "", ""
'This tests to see which buttons from 1 to 27 are pressed.
For a As Integer = 0 To 26
If (buttons And (1 Shl a)) Then
Print "Button "; a; " pressed. "
Else
Print "Button "; a; " not pressed."
End If
Next a
Loop</lang>
 
 
2,161

edits