WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-15-2016, 09:26 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
Smile

Hello again,

I hope I managed to implement what you meant, Erikvdb. I changed the while loop with a for loop and I loaded two of the screen textures outside of the loop, however, some textures I need to leave inside the loop, because it won't work otherwise. The screen 2 which is changing its picture, for example. I also tried adding the "picture = viz.add(pictureList[pictureIndex])" right after the pictureList and shuffling bit, but it won't work, it seems to want to be in the loop.

I did not really understand why I have to make the PictureIndex a global variable within the function, since I have defined it outside the function (which to my understanding already makes it a global variable), but it won't work otherwise.


Code:
import viz 																														
import viztask							
import random							

#Start Vizard:															
viz.go()

## STIMULI ##

#pictures
pictureA = viz.add('picA.jpg')
default = viz.add('default.png')

#sound
cue = viz.addAudio('dong.wav')

#list (7 times picture B and 3 times picture C)
pictureList = ['picB.png', 'picB.png', 'picB.png', 'picB.png', 'picB.png', 'picB.png', 'picB.png', 'picC.png', 'picC.png', 'picC.png']
random.shuffle(pictureList)
pictureIndex = 0

#Make a screen window:
screen1 = viz.addTexQuad(size=0.5)            
screen1.setPosition([0,2.1,1.3])
screen1.setSize([0.4, 0.4])

#Make a second screen window:
screen2 = viz.addTexQuad(size=0.5)            
screen2.setPosition([0,1.6,1.3])
screen2.setSize([0.4, 0.4])

screen1.texture(pictureA)
screen2.texture(default)
	
## TASK##

def task():
	screen1
	screen2

	def playCueLoop():  # default picture is shown in lower window + 10 times, at randomly intersperced intervals, a sound beep plays & each time that happens, the lower window replaces the default picture randomly with 7 times picB and 3 times pic C
		global pictureIndex
		for x in range(10):
			cue.play()
			yield viztask.waitTime(random.randrange(1,4))
			picture = viz.add(pictureList[pictureIndex])
			screen2.texture(picture)
			pictureIndex += 1
			yield viztask.waitTime(0.5)
			screen2.texture(default)
			yield viztask.waitTime(0)
	viztask.schedule (playCueLoop())

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

Tags
condition, loop, picture, sound

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
playing a sound multiple times at different timings jelly Vizard 3 02-04-2016 03:39 AM


All times are GMT -7. The time now is 07:20 AM.


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