
-----------------------------------
2F_Zelda
Tue Jun 07, 2011 10:31 pm

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.

-----------------------------------
Tony
Tue Jun 07, 2011 11:14 pm

Re: Problem with Mouse.ButtonWait
-----------------------------------
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.

-----------------------------------
2F_Zelda
Wed Jun 08, 2011 8:08 am

Re: Problem with Mouse.ButtonWait
-----------------------------------
Thanks, I got it now.


loop
    if Mouse.ButtonMoved ("down") then
        Mouse.ButtonWait ("down", x, y, a, b)
    else
        exit
    end if
end loop


-----------------------------------
2F_Zelda
Wed Jun 08, 2011 8:49 pm

Re: Problem with Mouse.ButtonWait
-----------------------------------
On second thought, would this be more efficient?


loop
    exit when not Mouse.ButtonMoved ("down")
    Mouse.ButtonWait ("down", x, y, a, b)
end loop


-----------------------------------
Tony
Wed Jun 08, 2011 8:57 pm

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 [tdoc]Mouse.Where[/tdoc] instead of ButtonWait.

-----------------------------------
2F_Zelda
Wed Jun 08, 2011 10:19 pm

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  :|
