Computer Science Canada

Help with Mouse.ButtonWait

Author:  Ktomislav [ 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

Author:  Tony [ 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.

Author:  Ktomislav [ Fri Sep 12, 2008 11:01 am ]
Post subject:  Re: Help with Mouse.ButtonWait

Thanks, Tony.

Author:  Warchamp7 [ 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

Author:  Tony [ 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.


: