WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 06-26-2008, 11:08 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I'm not sure what you mean by a 'nested if loop'. The if statement does not loop, it simply checks a condition and executes the nested code if the condition passes. The code you posted would never work because the key variable can never be equal to 'A' and 'D' at the same time.

One way to check for consecutive key presses is to save the last key press and compare it with the new one. Here is some sample code that does this. It also check how long has elapsed since the last press to make sure the keys were pressed in a short amount of time.
Code:
import viz
viz.go()

lastKey = None
lastKeyTime = 0.0
def onKeyDown(key):
	global lastKey,lastKeyTime
	
	elapsed = viz.tick() - lastKeyTime
	
	if lastKey == 'a' and key == 'd' and elapsed < 0.2:
		print 'ad pressed'
	
	lastKey = key
	lastKeyTime = viz.tick()
viz.callback(viz.KEYDOWN_EVENT,onKeyDown)
Reply With Quote
 


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
Custom Menu Options south_bank Vizard 5 07-07-2008 10:52 AM
What are the options for making a movie of a Vizard world? Karla Vizard 1 05-13-2008 10:56 AM
On Screen Keyboard betancourtb82 Vizard 14 10-03-2006 12:38 PM
Multiple Viewports in Vizard, Utilizing keyboard callback shivanangel Vizard 2 02-21-2006 04:56 PM
Timer vs. Keyboard input Wenamun Vizard 1 01-23-2006 09:04 PM


All times are GMT -7. The time now is 03:26 AM.


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