Joystick position: Difference between revisions

Content added Content deleted
m (whitespace)
Line 1: Line 1:
{{task}}
{{task|Joystick}}

The task is to determine the joystick position and represent this on the display via a crosshair.
The task is to determine the joystick position and represent this on the display via a crosshair.
For a centred joystick, the crosshair should appear in the centre of the screen. If the joystick is pushed left or right, then the cross hair should move left or right according to the extent that the joystick is pushed. If the joystick is pushed forward or pulled back, then the crosshair should move up or down according to the extent that that joystick is pushed or pulled. The edges
For a centred joystick, the crosshair should appear in the centre of the screen. If the joystick is pushed left or right, then the cross hair should move left or right according to the extent that the joystick is pushed. If the joystick is pushed forward or pulled back, then the crosshair should move up or down according to the extent that that joystick is pushed or pulled. The edges
Line 7: Line 6:


For the purpose of this task, we assume that the joystick is calibrated and that the first joystick is being used. The task implementer could at their option provide a solution that includes a joystick selection facility, enabling the user to choose which joystick is to be used for this task.
For the purpose of this task, we assume that the joystick is calibrated and that the first joystick is being used. The task implementer could at their option provide a solution that includes a joystick selection facility, enabling the user to choose which joystick is to be used for this task.

[[Category:Joystick]]


=={{header|GUISS}}==
=={{header|GUISS}}==
Line 91: Line 88:


=={{header|Locomotive Basic}}==
=={{header|Locomotive Basic}}==

<lang locobasic>10 MODE 1:BORDER 14:x=320:y=200:d=1
<lang locobasic>10 MODE 1:BORDER 14:x=320:y=200:d=1
20 a=JOY(0) ' read state of first joystick
20 a=JOY(0) ' read state of first joystick
Line 109: Line 105:


[[File:CPC drawing with joystick.png]]
[[File:CPC drawing with joystick.png]]



=={{header|Mathematica}}==
=={{header|Mathematica}}==

<lang Mathematica>Slider2D[Dynamic[ControllerState[{"X", "Y"}]], ImageSize -> {500, 500}]</lang>
<lang Mathematica>Slider2D[Dynamic[ControllerState[{"X", "Y"}]], ImageSize -> {500, 500}]</lang>


Line 159: Line 153:
(mouseFunc '((Btn State X Y) (bye)))
(mouseFunc '((Btn State X Y) (bye)))
(glutMainLoop)</lang>
(glutMainLoop)</lang>

=={{header|PureBasic}}==
=={{header|PureBasic}}==
This is limited to only digital joysticks.
This is limited to only digital joysticks.