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

Username:   Password: 
 RegisterRegister   
 Help with Mouse.ButtonWait
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ktomislav




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Ktomislav




PostPosted: Fri Sep 12, 2008 11:01 am   Post subject: Re: Help with Mouse.ButtonWait

Thanks, Tony.
Warchamp7




PostPosted: 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
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: