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

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




PostPosted: Tue Jun 07, 2011 10:31 pm   Post subject: Problem with Mouse.ButtonWait

What is it you are trying to achieve?
Me and a friend are making a game of Connect4, with one colour being controlled with the mouse and the other controlled with a few buttons via parallel port.


What is the problem you are having?
When it is the peripheral's turn, clicking the mouse won't do anything immediately, as it shouldn't. However, that click gets added to the mouse queue and it gets read by Mouse.ButtonWait as soon as it is the mouse's turn. Is there a way to clear the mouse queue so that this won't happen?


Describe what you have tried to solve this problem
I've looked through both the help file (F10) and searched this forum, but obviously I've found nothing, or this topic wouldn't exist.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Unfortunately, I am unable to provide code at the present time. I will be able to tomorrow morning, but I feel that my question can be answered without any code.

Please specify what version of Turing you are using
4.1.1

Thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jun 07, 2011 11:14 pm   Post subject: Re: Problem with Mouse.ButtonWait

2F_Zelda @ Tue Jun 07, 2011 10:31 pm wrote:
However, that click gets added to the mouse queue and it gets read by Mouse.ButtonWait as soon as it is the mouse's turn.

Hint: the click is removed from the queue when it's read.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
2F_Zelda




PostPosted: Wed Jun 08, 2011 8:08 am   Post subject: Re: Problem with Mouse.ButtonWait

Thanks, I got it now.

Turing:

loop
    if Mouse.ButtonMoved ("down") then
        Mouse.ButtonWait ("down", x, y, a, b)
    else
        exit
    end if
end loop
2F_Zelda




PostPosted: Wed Jun 08, 2011 8:49 pm   Post subject: Re: Problem with Mouse.ButtonWait

On second thought, would this be more efficient?

Turing:

loop
    exit when not Mouse.ButtonMoved ("down")
    Mouse.ButtonWait ("down", x, y, a, b)
end loop
Tony




PostPosted: Wed Jun 08, 2011 8:57 pm   Post subject: RE:Problem with Mouse.ButtonWait

Those two are functionally the same.

If a user manages to build up a queue such that clearing it is a problem, perhaps you can avoid the input queue all together with something like Mouse.Where instead of ButtonWait.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
2F_Zelda




PostPosted: Wed Jun 08, 2011 10:19 pm   Post subject: Re: Problem with Mouse.ButtonWait

Well, I usually design my programs to be able to function normally no matter what the user does, and I know that some of my friends may try and spam click. Also, I forget how, but I somehow convinced myself to use ButtonMoved and ButtonWait instead of Where. I consider myself to be a fairly logical person, so I'm pretty sure that my justification made sense, whatever it was Neutral
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  [ 6 Posts ]
Jump to:   


Style:  
Search: