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

Username:   Password: 
 RegisterRegister   
 Mousewhere
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
harishmabish




PostPosted: Sat Mar 29, 2008 7:36 pm   Post subject: Mousewhere

Can i have some clear instruction on how to use mousewhere?
I'm making a game, and I want a start button, I've tried using the mousewhere, but my coordinates are just not working.
I'm probably doing the whole thing wrong. Can someone give clear instructions?
Sponsor
Sponsor
Sponsor
sponsor
Sean




PostPosted: Sat Mar 29, 2008 8:11 pm   Post subject: Re: Mousewhere

To use Mouse.Where you need it to be in a loop..

Turing:

var mx, my, mb : int

loop
Mouse.Where (mx , my , mb) %This portion initlizes the Mouse.Where and keeps tracking every time, since it is within the loop.
end loop


You have drawn a button, using Draw.Box, you want to check to see if the mouse is between the boundaries of the box, and if the person clicked the button.

Turing:

var mx, my, mb : int

Draw.Box (100, 100, 200, 200, black) %This is going to be your button

loop
    Mouse.Where (mx, my, mb)
    if mx >= 100 and mx <= 200 and my >= 100 and my <= 200 and mb = 1 then %Checks to see if the mouse is between your button demensions, and if you clicked then it will print Hello
        cls
        put "Hello"
    end if
end loop


If you are using a procedure, you would replaces the put "Hello" with the procedure name.
Tony




PostPosted: Sat Mar 29, 2008 8:12 pm   Post subject: RE:Mousewhere

Mouse.Where assigns the values of the mouse (x, y, and button state), at the time the call is made, to the variables supplied.
Turing:

var x,y,b:int
loop
   Mouse.Where(x,y,b)
   locate(1,1)
   put "Your mouse is at: ", x, ", ", y
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
andrew.




PostPosted: Sat Apr 05, 2008 9:17 pm   Post subject: Re: Mousewhere

If you are using Mouse.Where for just a button, why not use GUI.CreateButton? It's less messy and easier to use. This is only for GUI stuff though (like buttons, text boxes, stuff like that).

If you want to use Mouse.Where for your actual game, use it like this.

Turing:
var x, y, button : int
loop
     Mouse.Where (x, y, button)
     put "Your mouse's position is: (", x, ",", y, ")"
     if button = 1 then
          put "Your mouse button is pressed."
     else
          put "Your mouse button is not pressed."
     end if
end loop


This is basically how to use it. Not very hard, but making buttons can be messy with it.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: