Board Logo
« shal i drive tester »

Welcome Guest. Please Login or Register.
Sep 23rd, 2017, 3:13pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: shal i drive tester  (Read 188 times)
bluatigro
Full Member
ImageImageImageImage


member is offline

Avatar

cxio difersas el tio respondas cxio samvaloras [ thats esperanto for : everybody is different therefore everybody is equal ]


PM

Gender: Male
Posts: 229
xx shal i drive tester
« Thread started on: Aug 23rd, 2017, 04:36am »

i m a litle woried about road savety
whit al the drugs around in trafic

you can't test for al drugs
so i decided to test for the effect of drugs

the most woring effect is reactiontime growth
so lets test for that

error :
i never see 'TAKE A CAB !!!'

? :
are the timespans right ?

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , dice , tel , start
winx = WindowWidth
winy = WindowHeight
nomainwin
button #m.btnStop , "STOP" , [btnStop] _
, UL , winx/2-50 , winy*2/3-50 , 100 , 100
menu #m , "test" _
        , "new" , [new] _
        , | , "exit" , [quit]
menu #m , "?" _
        , "info" , [info]
open "DRIVE TESTER 1.0" for graphics as #m
  #m "trapclose [quit]"
  #m "font 70 bold"
  #m "fill black"
wait
[new]
  dice = range( 5000 , 15000 )
  start = 0
  timer 1 , [timer]
wait
[timer]
  start = start + 1
  if start = dice then
    #m "goto ";winx/2-50;" ";winy/3-50
    #m "backcolor yellow"
    #m "down"
    #m "boxfilled ";winx/2+50;" ";winy/3+50
    #m "up"
  end if
  if start > dice then
    tel = tel + 1
  end if
  if tel > 2000 then
    timer 0
    notice "TAKE A CAB !!!"
  end if
wait
[btnStop]
  timer 0
  if start < dice then
    notice "YOU PRESED TO EARLY !!"
  else
    if tel < 100 then
      notice chr$( 13 ) _
      + "Reactiontime = " ; tel ; " ms." + chr$( 13 ) _
      + "you are fit to drive ."
    else
      if tel > 500 then
        notice chr$( 13 ) _
        + "Reactiontime = " ; tel ; " ms." + chr$( 13 ) _
        + "Take a cab !!"
      else
        notice chr$( 13 ) _
        + "Reactiontime = " ; tel ; " ms." + chr$( 13 ) _
        + "Drive slow ."
      end if
    end if
  end if
wait
[quit]
  close #m
end
function range( l , h )
  range = int( rnd(0) * ( h - l + 1 ) + l )
end function
[info]
  notice chr$( 13 ) _
  + "Welkome by drive tester ." + chr$( 13 ) _
  + "Instructions :" + chr$( 13 ) _
  + "push menu > test > new for new test ." + chr$( 13 ) _
  + "When yellow square is visable :" + chr$( 13 ) _
  + "push button 'stop' as quickly as posible" + chr$( 13 ) _
  + "Drive savely ."
wait
 
« Last Edit: Aug 23rd, 2017, 04:40am by bluatigro » User IP Logged

bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: shal i drive tester
« Reply #1 on: Aug 23rd, 2017, 12:19pm »

I am reminded of saying, "If you have to ask, you don't want to know."

With this test, one is going to sober up just waiting for the yellow square.

BTW, you can only take the test once because bluatigro never turns off the yellow square.
« Last Edit: Aug 23rd, 2017, 12:27pm by bplus » User IP Logged

B+
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3553
xx Re: shal i drive tester
« Reply #2 on: Aug 23rd, 2017, 1:28pm »

Quote:
are the timespans right ?

No
Timer ticks in minimal increments that is likely be 16 ms, even if you issue "timer 1"

So you need store time as
Code:
t0=time$("ms") 


and check time passed as
Code:
time$("ms")-t0 
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3553
xx Re: shal i drive tester
« Reply #3 on: Aug 23rd, 2017, 1:37pm »

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , dice , tel , start
winx = WindowWidth
winy = WindowHeight
nomainwin
button #m.btnStop , "STOP" , [btnStop] _
, UL , winx/2-50 , winy*2/3-50 , 100 , 100
menu #m , "test" _
        , "new" , [new] _
        , | , "exit" , [quit]
menu #m , "?" _
        , "info" , [info]
open "DRIVE TESTER 1.0" for graphics as #m
  #m "trapclose [quit]"
  #m "font 70 bold"
  #m "fill black"
'wait
[new]
    #m "fill black"
  dice = range( 5000 , 15000 )
  t0=time$("ms")
  start = 0
  tel =0
  timer 1 , [timer]
wait
[timer]
  start = time$("ms")-t0
  if start >= dice then
    #m "goto ";winx/2-50;" ";winy/3-50
    #m "backcolor yellow"
    #m "down"
    #m "boxfilled ";winx/2+50;" ";winy/3+50
    #m "up"
  end if
  if start > dice then
    tel = time$("ms")-t0 - dice
  end if
  if tel > 2000 then
    timer 0
    notice "TAKE A CAB !!!"
  end if
wait
[btnStop]
  timer 0
  if start < dice then
    notice "YOU PRESED TO EARLY !!"
  else
    if tel < 100 then
      notice chr$( 13 ) _
      + "Reactiontime = " ; tel ; " ms." + chr$( 13 ) _
      + "you are fit to drive ."
    else
      if tel > 500 then
        notice chr$( 13 ) _
        + "Reactiontime = " ; tel ; " ms." + chr$( 13 ) _
        + "Take a cab !!"
      else
        notice chr$( 13 ) _
        + "Reactiontime = " ; tel ; " ms." + chr$( 13 ) _
        + "Drive slow ."
      end if
    end if
  end if
wait
[quit]
  close #m
end
function range( l , h )
  range = int( rnd(0) * ( h - l + 1 ) + l )
end function
[info]
  notice chr$( 13 ) _
  + "Welkome by drive tester ." + chr$( 13 ) _
  + "Instructions :" + chr$( 13 ) _
  + "push menu > test > new for new test ." + chr$( 13 ) _
  + "When yellow square is visable :" + chr$( 13 ) _
  + "push button 'stop' as quickly as posible" + chr$( 13 ) _
  + "Drive savely ."
wait
 
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: shal i drive tester
« Reply #4 on: Aug 24th, 2017, 12:38pm »

Ha! I played around with this last night thinking it might be done without the timer. I used the pause sub to delay the random, "dice", time to show the yellow "Stop" square.

Funny thing was that every time I clicked the stop button early, before the yellow square showed, I was "fit to drive" with almost a perfect 0 reaction time. What? That's not right. Took me too long to figure out why. grin

If I waited to see the yellow square, I was lucky if I were quick enough to just get the warning to drive slow, most of the time I was told to get a taxi. So I think Bluatigro's numbers are a little tight, of course these things are different on different systems. Maybe I should not drive anymore. wink

Maybe just use the timer (once for each test) to show the yellow square. That way button events before and after the display can still happen and be recorded and timed?

PS oh also, wouldn't it be interesting to use a Stop menu item instead of a Stop button. That takes more sober skills to use than just clicking a Stop button (and would be easier to program).
« Last Edit: Aug 24th, 2017, 12:55pm by bplus » User IP Logged

B+
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: shal i drive tester
« Reply #5 on: Aug 24th, 2017, 3:10pm »

Proof of concept:

Code:
WindowWidth = 600
WindowHeight = 400

nomainwin

menu #m , "Test", "Start", [new], "Stop", [Stop], | , "exit" , [quit]
menu #m , "Help", "Directions" , [info]
open "DRIVER REACTION TIME TESTER 1.0 by bluatigro mods tsh73 and bplus" for graphics as #m
    #m "trapclose [quit]"
    #m "fill black"
wait

[new]
    #m "fill black"
    rShow = range(1500, 4500)
    t0 = time$("ms")
    timer 100, [timer]
wait

[timer]
    if time$("ms") >= t0 + rShow then
        timer 0
        #m "fill yellow"
    end if
wait

[Stop]
    timer 0
    tTime = time$("ms") - (t0 + rShow)
    #m "fill black"
    if tTime < 0 then
        notice "YOU PRESSED TOO EARLY !!"
    else
        if tTime < 500 then
            notice "You are fit to drive."
        else
            if tTime > 1000 then
                notice "Take a cab!"
            else
                notice "A little slow, drive slow."
            end if
        end if
    end if
wait

[info]
  notice "Directions:" + chr$(13)_
  + "Welcome to Reaction Time Tester" + chr$(10) + chr$(10)_
  + "To start, click menu > Test > Start" + chr$(10) + chr$(10)_
  + "When see yellow," + chr$(10)_
  + "click menu > Test > Stop " + chr$(10)_
  + "As Soon As Possible!" + chr$(10) + chr$(10)_
  + "Your reaction time will then be measured." + chr$(10)_
  + chr$(10) + "Drive safely!"
wait

[quit]
    timer 0
    close #m
end

function range(l, h)
  range = int(rnd(0) * (h - l + 1) + l)
end function
 
User IP Logged

B+
bluatigro
Full Member
ImageImageImageImage


member is offline

Avatar

cxio difersas el tio respondas cxio samvaloras [ thats esperanto for : everybody is different therefore everybody is equal ]


PM

Gender: Male
Posts: 229
xx Re: shal i drive tester
« Reply #6 on: Aug 31st, 2017, 04:11am »

@ al :
thanks for help

update :
i build button's in

Code:
WindowWidth = 600
WindowHeight = 400

winx = 600
winy = 400
nomainwin

button #m.start , "Start" , [new] _
, UL , winx/2-150,0,300,100
button #m.stop , "Stop" , [Stop] _
, UL , winx/2-150,winy-200,300,100
menu #m , "Help", "Directions" , [info]
open "DRIVER REACTION TIME TESTER 2.0 by bluatigro mods tsh73 and bplus" for graphics as #m
    #m "trapclose [quit]"
    #m "fill black"
    #m.start "!font 50 bold"
    #m.stop "!font 50 bold"
wait

[new]
    #m "fill black"
    rShow = range(1500, 4500)
    t0 = time$("ms")
    timer 100, [timer]
wait

[timer]
    if time$("ms") >= t0 + rShow then
        timer 0
        #m "fill yellow"
    end if
wait

[Stop]
    timer 0
    tTime = time$("ms") - (t0 + rShow)
    #m "fill black"
    if tTime < 0 then
        notice "YOU PRESSED TOO EARLY !!"
    else
        if tTime < 500 then
            notice "You are fit to drive."
        else
            if tTime > 1000 then
                notice "Take a cab!"
            else
                notice "A little slow, drive slow."
            end if
        end if
    end if
wait

[info]
  notice "Directions:" + chr$(13)_
  + "Welcome to Reaction Time Tester" + chr$(10) + chr$(10)_
  + "To start, click menu > Test > Start" + chr$(10) + chr$(10)_
  + "When see yellow," + chr$(10)_
  + "click menu > Test > Stop " + chr$(10)_
  + "As Soon As Possible!" + chr$(10) + chr$(10)_
  + "Your reaction time will then be measured." + chr$(10)_
  + chr$(10) + "Drive safely!"
wait

[quit]
  timer 0
  close #m
end

function range(l, h)
  range = int(rnd(0) * (h - l + 1) + l)
end function

 
User IP Logged

bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1157
xx Re: shal i drive tester
« Reply #7 on: Aug 31st, 2017, 11:52am »

Yep, buttons are allot easier!

Might want to update instructions.
User IP Logged

B+
bluatigro
Full Member
ImageImageImageImage


member is offline

Avatar

cxio difersas el tio respondas cxio samvaloras [ thats esperanto for : everybody is different therefore everybody is equal ]


PM

Gender: Male
Posts: 229
xx Re: shal i drive tester
« Reply #8 on: Sep 1st, 2017, 04:02am »

@ bplus :
thinked about instrucions after posting

update :
new instructions

Code:
WindowWidth = 600
WindowHeight = 400

winx = 600
winy = 400
nomainwin

button #m.start , "Start" , [new] _
, UL , winx/2-150,0,300,100
button #m.stop , "Stop" , [Stop] _
, UL , winx/2-150,winy-200,300,100
menu #m , "Help", "Directions" , [info]
open "DRIVER REACTION TIME TESTER 2.0 by bluatigro mods tsh73 and bplus" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  #m.start "!font 50 bold"
  #m.stop "!font 50 bold"
wait

[new]
  #m "fill black"
  rShow = range(1500, 4500)
  t0 = time$("ms")
  timer 100, [timer]
wait

[timer]
  if time$("ms") >= t0 + rShow then
    timer 0
    #m "fill yellow"
  end if
wait

[Stop]
  timer 0
  tTime = time$("ms") - (t0 + rShow)
  #m "fill black"
  if tTime < 0 then
    notice "YOU PRESSED TOO EARLY !!"
  else
    if tTime < 500 then
      notice "You are fit to drive."
    else
      if tTime > 1000 then
        notice "Take a cab!"
      else
        notice "A little slow, drive slow."
      end if
    end if
  end if
wait

[info]
  notice "Directions:" + chr$(13)_
  + "Welcome to Reaction Time Tester ." + chr$(10) + chr$(10)_
  + "To start , click button [Start]" + chr$(10) + chr$(10)_
  + "When you see yellow ," + chr$(10)_
  + "click button [Stop]" + chr$(10)_
  + "As Soon As Possible !" + chr$(10) + chr$(10)_
  + "Your reaction time will then be measured ." + chr$(10)_
  + chr$(10) + "Drive safely !"
wait

[quit]
  timer 0
  close #m
end

function range(l, h)
  range = int(rnd(0) * (h - l + 1) + l)
end function
 
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls