WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-07-2014, 03:23 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could log the reaction time and then yield for an additional amount of time equal to 3 seconds minus the reaction time:

Code:
import viz
import viztask
viz.go()

def MyTask():
	
	waitKey = viztask.waitKeyDown(' ')
	waitTime = viztask.waitTime(3)
	
	while True:
		
		print 'start'

		#Wait for next frame to be drawn to screen
		d = yield viztask.waitDraw()

		#Save start time
		startTime = d.time

		d = yield viztask.waitAny( [ waitKey, waitTime ] )
		
		if d.condition is waitKey:
			keyData = d.data
			elapsed = keyData.time - startTime
			print 'The spacebar was pressed after {:.2f} seconds'.format(elapsed)
			yield viztask.waitTime(3-elapsed)
			
		elif d.condition is waitTime:
			print '3 seconds passed, the spacebar was not pressed'

viztask.schedule( MyTask() )
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
exact copy of mainview in second window dcnieho Vizard 1 06-30-2014 04:02 PM
Window always on top madeinjava Vizard 4 08-27-2013 02:10 PM
Unexpected Change of Window Size javadi Vizard 7 07-23-2013 02:56 PM
Inconsistent timestamp while logging mape2k Vizard 4 07-15-2013 06:03 AM
timer question Elittdogg Vizard 5 10-10-2007 02:49 PM


All times are GMT -7. The time now is 04:45 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC