Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how do i...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rollerdude




PostPosted: Wed Sep 15, 2004 4:27 pm   Post subject: how do i...

can someone give me cmds, for the mouse as an input device and joystick as an input device and how to use the commands

and what does "ord" mean
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Sep 15, 2004 4:54 pm   Post subject: (No subject)

for mouse as input:
The Turing Reference wrote:

Mouse.Where Part of Mouse module

Syntax Mouse.Where (var x, y, button : int)

Description The Mouse.Where procedure is used to get current information about the status of the mouse. The parameters x and y are set to the current location of the mouse cursor. If the program is running on a system using windows, the cursor may be outside the window. This means that x and y may be set to values outside of the bounds of 0 to maxx and 0 to maxy.
The parameter button is set depending on the current mode. In "single-button mode" (where the mouse is treated like a one-button mouse), button is set to 0 if all the mouse buttons are up, and 1 if any of the mouse buttons are down. In "multi-button mode", button is assigned the sum of 1 if the left button is down, 10 if the middle button is down, and 100 if the right button is down. Thus if button has the value of 101, then it means that the left and right mouse buttons were depressed.


Example A program that displays the status of the mouse at the top left corner of the screen.

var x, y, button : int
loop
Mouse.Where (x, y, button)
Text.Locate (1, 1)
if button = 0 then
put x : 4, " ", y : 4, " button up"
else
put x : 4, " ", y : 4, " button down"
end if
end loop

Status Exported qualified.
This means that you can only call the function by calling Mouse.Where, not by calling Where.


See also Mouse.ButtonMoved and Mouse.ButtonWait to get mouse events saved in a queue. See also Mouse.ButtonChoose to switch between "single-button mode" and "multi-button mode".


as for joysticks..

The Turing Reference wrote:

Joystick.GetInfo Part of Joystick module

Syntax Joystick.GetInfo (joystick : int, var xPos, yPos : int,
btn1Pressed, btn2Pressed : boolean)

Description Reads the position and button status of the joystick specified by the joystack parameter. The x and y parameter are returned in the xPos and yPos parameters. If button 1 or button 2 on the joystick are currently pressed, btn1Pressed and btn2Pressed will be set to true. The joystick parameter can be either joystick1 or joystick2.
The x and y positions vary from joyMin to joyMax. To use them with respect to a screen, the coordinates returned from Joystick.GetInfo must be translated into screen coordinates. The following formula can be used:


screenX = round (maxx * (xPos joyMin) / (joyMax joyMin))
screenY = round (maxy * (yPos joyMin) / (joyMax joyMin))

Details The Joystick module contains undocumented subprograms for those who need to access more than two buttons or axes on a joystick. Contact Holt Software if you need more information.

Example The following program outputs the current location of joystick #1 and draws a cursor on the screen to point out where it is showing.

var jx, jy, x, y, ox, oy : int := 1
var b1, b2, oB1, oB2 : boolean := false
loop
Joystick.GetInfo (joystick1, jx, jy, b1, b2)
% Convert joystick coordinates into screen coordinates.
x = round (maxx * (jx joyMin) / (joyMax joyMin))
y = round (maxy * (jy joyMin) / (joyMax joyMin))
if x not= ox or y not= oy or b1 not= oB1 or b2 not= oB2 then
Text.Locate (1, 1)
put "x = ", x, " y = ", y, " b1 = ", b1, " b2 = ", b2
View.Set ("xor")
Draw.Line (ox 10, oy, ox + 10, oy, brightred)
Draw.Line (ox , oy 10, ox , oy + 10, brightred)
Draw.Line (x 10, y, x + 10, y, brightred)
Draw.Line (x, y 10, x, y + 10, brightred)
ox := x
oy := y
oB1 := b1
oB2 := b2
end if
end loop

Status Exported qualified.
This means that you can only call the function by calling Joystick.GetInfo, not by calling GetInfo


as for ord.. I'm not sure why its called ord, but basically what it does is takes a single character (a string with a length of 1) and returns the ASCII number for that character.

when in Turing, hit f10, and go to Turing Language --> Keystroke Codes to see a list of the ASCII codes.

so, ord("A") returns 65, whereas ord("a") returns 97.
rollerdude




PostPosted: Wed Sep 15, 2004 4:58 pm   Post subject: (No subject)

thanks alot! (no sarcasm)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: