visible = false started = false inited = false timerdelay = 0.01 delay = 0 visibleappear = 0.002 scrWidth = 0 scrHeight = 0 x=0 y=0 r=0 border=10 lst = {} n = 1 malus = 100 maxessais = 30 m = 1 action = false function on.timer() if action then if(visible) then visible = false lst[n]=delay n=n+1 if(n>maxessais) then started = false var.store("resultats"..m,lst) m = m+1 end platform.window:invalidate() delay=0 else delay=delay+malus end action = false end if(started and not visible) then if math.random()<=visibleappear then visible = true x=border+math.random()*(scrWidth-2*border) y=border+math.random()*(scrHeight-2*border) r=border+math.random()*(math.min(math.min(x,scrWidth-x)-border,math.min(y,scrHeight-y)-border)) platform.window:invalidate() end else delay = delay + timerdelay end end function on.paint(gc) if(not inited) then scrWidth = platform.window:width() scrHeight = platform.window:height() if(scrWidth>0 and scrHeight>0) then inited = true timer.start(timerdelay) end end gc:setFont("serif","r",8) if(started) then if(visible) then cursor.show() gc:setColorRGB(255,0,0) gc:fillArc(x,y,r,r,0,360) gc:setColorRGB(0,0,0) gc:drawArc(x,y,r,r,0,360) end gc:drawString("Serie de tests "..m,0,0,"top") gc:drawString("Test "..n.."/"..maxessais,0,10,"top") if(n>1) then gc:drawString("Dernier temps de reaction: "..lst[n-1].."s",0,20,"top") end else gc:drawString("Taper 'S' pour demarrer le test "..m,0,0,"top") end end function on.charIn(s) if(s=="s" and not started) then started = true n = 1 delay=0 platform.window:invalidate() end end function on.mouseDown() action = true end function on.arrowKey() action = true end