Help with Mouse.ButtonWait
Author |
Message |
Ktomislav
![](http://compsci.ca/v3/uploads/user_avatars/208162377548d53ef771951.jpg)
|
Posted: Fri Sep 12, 2008 9:56 am Post subject: Help with Mouse.ButtonWait |
|
|
Hi, I'm new here.
I have a little problem. How can i stop the program form saving all my clicks with mouse.
The problem is that program saves all my clicks even if it is in delay command.
Here is an example. If i click fast at this box the program will write "Help" more times than
it should.
code: |
Draw.Box(1, 1, 100, 100, black)
var x, y, button, buttonupdown : int;
loop
Mouse.ButtonWait("down", x, y, button, buttonupdown)
if (button = 1) then
put "Help"
delay(1000)
end if
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Sep 12, 2008 10:32 am Post subject: RE:Help with Mouse.ButtonWait |
|
|
You should check the documentation to make sure that's the case, but it sounds like Mouse.ButtonWait will write (or rather read I guess) events from a buffer (same effect as typing on a keyboard really fast, and then using getch).
Try using edit: Mouse.Where to get the state at that instance. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Ktomislav
![](http://compsci.ca/v3/uploads/user_avatars/208162377548d53ef771951.jpg)
|
Posted: Fri Sep 12, 2008 11:01 am Post subject: Re: Help with Mouse.ButtonWait |
|
|
Thanks, Tony. |
|
|
|
|
![](images/spacer.gif) |
Warchamp7
![](http://compsci.ca/v3/uploads/user_avatars/1427564341464495e84ae65.gif)
|
Posted: Fri Sep 12, 2008 12:17 pm Post subject: RE:Help with Mouse.ButtonWait |
|
|
In my game, I use Mouse.Where (x, y, Button State : int) to get the position of the mouse and its state.
Then I check if the mouse's x and y coordinates are inside those of my game's buttons. If it's inside that box and button = 1 (A button is down) then it registers it as clicked.
I have the code below but with this method, you can hold the mouse button down and it will keep firing.
Turing: | Draw.Box(1, 1, 100, 100, black)
var x, y, button, buttonupdown : int;
loop
Mouse.Where (x, y, button )
if x <= 100 and x >= 1 and y <= 100 and y >= and button = 1 then
put "Help"
delay(1000)
end if
end loop |
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Sep 12, 2008 12:30 pm Post subject: Re: RE:Help with Mouse.ButtonWait |
|
|
Warchamp7 @ Fri Sep 12, 2008 12:17 pm wrote: In my game, I use Mouse.Where
Thx. I think that's what I meant to say. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
|
|