STICK

From QB64 Wiki
Revision as of 20:22, 21 June 2011 by imported>Clippy
Jump to navigation Jump to search

The STICK function returns the directional coordinate move of game port (&H201) joysticks.


Syntax

coordinate_move% = STICK(direction%)


QB64 == Syntax ==

coordinate_move% = STICK(direction%[, 2])


Description:

  • Qbasic direction values are only 0 to 3 for 2 joysticks maximum.
  • QB64 allows any number of coordinate pairs for more than two joystick controls.
  • 2 can be used as the second parameter for controllers with dual controlled sticks using the SAME directional parameters.
  • Returns coordinate values from 1 to 200.
  • STICK(0) is required to get values from the other STICK functions. Always read it first!

STICK(0) returns the column coordinate of joystick A. Enables reads of the other STICK values. STICK(1) returns row coordinate of joystick A. STICK(2) returns column coordinate of joystick B. (second joystick if used) STICK(3) returns row coordinate of joystick B if used. STICK(4) returns column coordinate of joystick C. (other joysticks if used in QB64 only!) STICK(5) returns row coordinate of joystick C if used.

  • QB64 allows more joysticks by extending the numbers in pairs like joystick C above. EX: STICK(6): STICK(7)
  • QB64 allows a second stick to be read using the same first parameters and 2 as the second parameter. EX: STICK(0, 2)
  • Note: Only resistance type joysticks can be read by STICK. Digital types cannot be read!


Example: Displays the input from 3 joysticks, all with dual sticks and 3 buttons.

DO: _LIMIT 10 LOCATE 1, 1 PRINT "JOY1: STICK"; STICK(0); STICK(1); STICK(0, 2); STICK(1, 2);_ "STRIG"; STRIG(0); STRIG(1); STRIG(4); STRIG(5); STRIG(8); STRIG(9) PRINT "JOY2: STICK"; STICK(2); STICK(3); STICK(2, 2); STICK(3, 2);_ "STRIG"; STRIG(2); STRIG(3); STRIG(6); STRIG(7); STRIG(10); STRIG(11) PRINT "JOY3: STICK"; STICK(4); STICK(5); STICK(4, 2); STICK(5, 2);_ "STRIG"; STRIG(0, 3); STRIG(1, 3); STRIG(4, 3); STRIG(5, 3); STRIG(8, 3); STRIG(9, 3) LOOP UNTIL INKEY$ > ""

Explanation: Notice the extra QB64 only parameters used to cater for the 2nd stick and the buttons of the 3rd joystick.


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page