fast score counter
Author |
Message |
msimard8
|
Posted: 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
|
|
|
[Gandalf]
|
Posted: 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
|
Posted: 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
|
Posted: 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]
|
Posted: 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
|
Posted: 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
and put in...
*******
I just mentioned that cause you said somthing about a *fast* counter...?? |
|
|
|
|
|
[Gandalf]
|
Posted: 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
|
Posted: 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
|
|
|
Tony
|
Posted: 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
|
|
|
|
|
|
|
|