Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,446 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Reaction Timer #262619
04/24/09 22:07
04/24/09 22:07
Joined: Apr 2009
Posts: 27
Silicon Valley
D
Dillinger Offline OP
Newbie
Dillinger  Offline OP
Newbie
D

Joined: Apr 2009
Posts: 27
Silicon Valley
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);
	}

}



Re: Reaction Timer [Re: Dillinger] #262624
04/24/09 23:18
04/24/09 23:18
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

This might help smile

Go to the search area at the top and write timer.

There was a discussion on this topic a while back ...you will find it.

Ottawa smile

Re: Reaction Timer [Re: Ottawa] #262698
04/25/09 09:22
04/25/09 09:22
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
AUM 32, car AI timer example smile


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: Milliseconds [Re: Jaxas] #284577
08/14/09 02:14
08/14/09 02:14
Joined: Apr 2009
Posts: 27
Silicon Valley
D
Dillinger Offline OP
Newbie
Dillinger  Offline OP
Newbie
D

Joined: Apr 2009
Posts: 27
Silicon Valley
I appreciate the help. I looked at the tutorial and, although it claims to show you how to make a millisecond timer, it is actaually psuedo-milliseconds. He's getting a value by dividing 1 second by a known value. So the "milliseconds" are always 0.333, 0.666, 1 , 1.333, etc..
That is not true milliseconds. That's like saying you can create a high resolution image by simply taking a small lo res image off the web and increasing the resolution in Photoshop.

There must be some way of accessing a faster system clock than referencing the frame rate of your game

Re: Milliseconds [Re: Dillinger] #284592
08/14/09 05:58
08/14/09 05:58
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Try this... Any problems or queries, let me know.
Code:
//////////////////////////////////////////////////////////////
// ms_timer() = 'timer()'-like function for milliseconds
//////////////////////////////////////////////////////////////
// Usage:
//   ms_timer(1);		   //reset timer to zero
//   var xxx = ms_timer(0);	   //retrieve milliseconds since last reset
//////////////////////////////////////////////////////////////
//
long __stdcall GetTickCount();
#define PRAGMA_API GetTickCount;kernel32!GetTickCount
long ms_timer(var init)
{	static long StartTime = GetTickCount();
	if(init)	StartTime = GetTickCount();
	return(GetTickCount() - StartTime);
}
//
//////////////////////////////////////////////////////////////




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1