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

Username:   Password: 
 RegisterRegister   
 With this code, how do i do this: the amount of time the mouse clicks without the user pressing the button constantly.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
turing1094




PostPosted: Mon Jun 14, 2010 10:47 am   Post subject: With this code, how do i do this: the amount of time the mouse clicks without the user pressing the button constantly.

What is it you are trying to achieve?
I need to make the user click on the blue circle and evertime they do that it records it, so it gives the results after a certain period of time, however you can just press and hold the button, how do i change this.


What is the problem you are having?
read above

Describe what you have tried to solve this problem
cant solve it
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


setscreen ("graphics:vga")
var count : int:=0
var x, y : int
var button : int := 0
var timepassed : boolean := false
var timepassed1 : int := 0
Draw.FillOval (300, 200, 50, 50, blue)
loop
    Mouse.Where (x, y, button)
    if button = 1
            then
        count := count + 1
    end if
    timepassed1 := timepassed1 + 1
delay(1)
    if timepassed1 > 1000
            then
        timepassed := true
    end if
    exit when timepassed = true
end loop
put "Your score is ", count




Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
copthesaint




PostPosted: Mon Jun 14, 2010 11:09 am   Post subject: RE:With this code, how do i do this: the amount of time the mouse clicks without the user pressing the button constantly

Turing:
View.Set ("Graphics,Offscreenonly,Nobuttonbar")
var x : int := 0
var mx, my, mb : int
var reset, clicked : boolean := false
loop
    %%%%%%%%%%%%%%%%%%
    Mouse.Where (mx, my, mb)
    %if mouse is not pressed, and reset is true then reset = false
    if mb = 0 and reset = true then
        reset := false
    end if
    %if the mouse is pressed and reset is false then clicked = true and reset = true
    if mb ~= 0 and reset = false then
        clicked := true
        reset := true
    end if
    %%%%%%%%%%%%%%%%%%
    %when the mouse is clicked, do this ->
    if clicked = true then
        x += 1
    end if



    put x
    View.Update
    cls
    %sets clicked so that it is only true for one loop after clicked.
    clicked := false
end loop
Tony




PostPosted: Mon Jun 14, 2010 11:14 am   Post subject: RE:With this code, how do i do this: the amount of time the mouse clicks without the user pressing the button constantly

The detail to copthesaint's post is that you record the mouse state over 2 instances in time. 2 binary choices give you 4 possible mouse states:

-- clicked down
-- held down
-- released
-- held released
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
chrisbrown




PostPosted: Mon Jun 14, 2010 11:33 am   Post subject: Re: RE:With this code, how do i do this: the amount of time the mouse clicks without the user pressing the button consta

Mouse.ButtonMoved and Mouse.ButtonWait are higher-level alternatives that take care of the details for you, if you prefer.
Cezna




PostPosted: Tue Jun 15, 2010 3:08 pm   Post subject: RE:With this code, how do i do this: the amount of time the mouse clicks without the user pressing the button constantly

This is the method I normally use:

Turing:

if button = 1 then
    if not clicked then
        % your code in here%
    end if
    clicked := true
else
    clicked := false
end if
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: