Forum Archive

script measuring reaction time

role

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

brumm

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.

ccc

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.