Hi Ya'll,
New to Lite-C and C programming.
I wanted to measure reaction time in thousandths of a second like so:
"Your reaction time was: 0.7653 seconds"
I tried a bunch of things; I tried starting with timer() and divide the microseconds by 1000000. but when you go over 1 second it flips to a negative number so I don't think it's good for that. I was trying to use time_frame, but the results seem chunky and not very accurate. Using seconds and dividing that would only give me a rounded off number as well, right?

Does anybody know how I can accurately time your reaction in 1000ths or so?

Thanks

Here's a rudimentary example:


Code:
 
#include <acknex.h>
#include <default.c>
fps_max = 60 ; 

var randomNumber = 0 ;  
var asciiInput = 0 ; 
var elapsed_time = 0 ; 
var reactionTime = 0 ; 
var counter = 0 ; 

var guessing = 0 ; 
STRING* tempString = " " ; 

PANEL* onscreenVariables =
{
	digits( 35, 20, "randomNumber = %0.f", Arial#20b, 1, randomNumber ) ; 
	digits( 35, 34, "elapsed_time = %0.5f", Arial#20b, 1, elapsed_time ) ; 
	digits( 35, 82, "time_frame = %0.5f", Arial#20b, 1, time_frame ) ; 
	digits( 35, 98, "reactionTime = %0.5f", Arial#20b, 1, reactionTime ) ; 
	flags = VISIBLE;
}

function main()
{
video_set( 1024, 768, 32, 2 ) ; 
random_seed( 0 ) ; 

 // MAIN GAME LOOP //

	while(1) 
	{   
		if (!guessing)
		{
		randomNumber = 0 ; 
		wait( 400 ) ; 
		randomNumber = ( integer( random(4) ) + 1 ) ; 

		guessing = 1 ; 	
		}
		
		if ( guessing ) 
		{
			asciiInput = inchar( tempString ) ; 
			elapsed_time = time_frame * 1000 / 16 ; 
			
			if ( randomNumber == ( asciiInput - 48 ) ) 
			{
				reactionTime = elapsed_time ; 
				elapsed_time = 0 ; 
				guessing = 0 ; 
			}
			
		}

	wait(1);
	}

}