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

Username:   Password: 
 RegisterRegister   
 fast score counter
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
msimard8




PostPosted: Mon Oct 10, 2005 5:07 pm   Post subject: fast score counter

code:
var mx, my,mc:int:=0
var score:=10

loop
mousewhere (mx,my,mc)

drawfillbox (200,200,400,500,red)

if mx > 200 and mx < 400 and my > 200 and my <500 and mc=1 then
score:=score+10
end if

locate (1,1)
put score ..

end loop



Ok how do I restrict the score counter to 10 points a click.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Mon Oct 10, 2005 5:25 pm   Post subject: (No subject)

You can change clickTime to anything you want, it matters on how long you think a click lasts before another click can be made. The wait time (clickTime) is in milliseconds.
Turing:
var mx, my, mc : int := 0
var score := 10
var lastClickTime : int := 0
var clickLength : int := 100

loop
    mousewhere (mx, my, mc)
    drawfillbox (200, 200, 400, 500, red)
    if mx > 200 and mx < 400 and my > 200 and my < 500 and mc = 1 and Time.Elapsed - lastClickTime > clickLength then
        score += 10
        lastClickTime := Time.Elapsed
    end if
    locate (1, 1)
    put score ..
end loop
Tony




PostPosted: Mon Oct 10, 2005 6:42 pm   Post subject: (No subject)

the mouse button could still be held down and the score would count after every interval.

you should monitor for mouse release instead. User presses mouse down -- mc = 1. User releases the mouse -- mc = 0. That's when the score counts.
Token




PostPosted: Mon Oct 10, 2005 8:09 pm   Post subject: (No subject)

TADA!
code:
var mx, my, mc : int := 0
var score := 10

loop
    mousewhere (mx, my, mc)

    drawfillbox (200, 200, 400, 500, red)

    if mx > 200 and mx < 400 and my > 200 and my < 500 and mc = 1 then

        score += 10
    end if

    loop
        mousewhere (mx, my, mc)
        exit when mc = 0
        locate (1, 1)
        put score
    end loop

    locate (1, 1)
    put score

end loop


probibly not the most efficient way to do it, but it works. and it gives you an idea
[Gandalf]




PostPosted: Mon Oct 10, 2005 8:36 pm   Post subject: (No subject)

No... that wouldn't work at all... That loop messes up a lot, and limits you from doing a lot - efficiency has little to do with it.

Turing:
setscreen ("offscreenonly")
var mx, my, mc : int := 0
var score := 10
var mouseDown : boolean := false

loop
    cls
    mousewhere (mx, my, mc)
    drawfillbox (200, 200, 400, 500, red)
    if mx > 200 and mx < 400 and my > 200 and my < 500 and mc = 1 and mouseDown = false then
        mouseDown := true
        score += 10
    elsif mc < 1 then
        mouseDown := false
    end if
    put score
    View.Update
end loop
TokenHerbz




PostPosted: Mon Oct 10, 2005 11:28 pm   Post subject: (No subject)

If you want it to be able to click and hold, for the score to go sky hi,

Modify "Gandalfs" code

code:

elsif mc < 1 then


and put in...

code:

else


*******
I just mentioned that cause you said somthing about a *fast* counter...??
[Gandalf]




PostPosted: Mon Oct 10, 2005 11:30 pm   Post subject: (No subject)

Then you would also have to keep in mind that that 'else' would include if the right or middle mouse button are pressed, so that would be a way of "cheating".
TokenHerbz




PostPosted: Mon Oct 10, 2005 11:45 pm   Post subject: (No subject)

eh, really??

button = 1 is left click,
0 = no click

whats right, and middle click?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Oct 11, 2005 7:30 am   Post subject: (No subject)

tokenherbz wrote:
whats right, and middle click?

middle = 10
right = 100

but you have to
Turing:

Mouse.ButtonChoose ("multibutton")
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  [ 9 Posts ]
Jump to:   


Style:  
Search: