omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    script measuring reaction time

    Pythonista
    3
    3
    1707
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • role
      role last edited by

      Hi all,

      I am trying to write a script to measure reaction time.

      It should show the 10 digits as buttons, then show a random digit and the user has to tap the same digit as fast as possible.

      Here are my initial thoughts:

      • "buttons": copy from one of the calculators
      • random number: take out of the example script
      • Show digit: got it
      • time to reaction...

      Here is where I got stuck...
      I was thinking of simple variables (starttime = time() ) and endtime = time()) to measure the elapsed time, but I don't know where to put it...

      I tired to put starttime in the setup for my scene and endtime in the touch_began, but it seems that they cannot share variables...

      any tips?

      Thanks,

      Roland

      1 Reply Last reply Reply Quote 0
      • brumm
        brumm last edited by

        Hi Roland, there's an nice example called Stopwatch.py (Pythonista examples). Start and stop time is defined in the setup and then set in the touch-function.

        1 Reply Last reply Reply Quote 0
        • ccc
          ccc last edited by

          Perfect response... The actual code from Stopwatch.py is:

          self.start_time = 0.0
          self.stop_time = 0.0
          

          The 'self.' is the way to allow all methods of your scene to share the same variables.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors