Mousewhere
Author |
Message |
harishmabish
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Sean
![](http://compsci.ca/v3/uploads/user_avatars/47413941748406f441f83e.png)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
|
|