Thread: Tasks
View Single Post
  #1  
Old 01-05-2010, 08:53 AM
Moh200jo Moh200jo is offline
Member
 
Join Date: Feb 2009
Posts: 99
Tasks

I am using collision detection between Box1 and Box2 to count ball lob in a game. I am struggling to calculate balls number depends on this specific collision. I know I have to use function of the collision to do so.
I do not know how I can send information to the task1 from collision function to start add 1 to ball, the code I am using to do so as follows:
To detect the collision between Box1 and Box2 I am using the following code:
Code:
def onCollideBegin(e):
	if e.obj1 == box1 and  e.obj2== box2:
                      print e.obj1 , “    ,” , e.obj2
viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin)
if collision happened I have to add 1 to ball
Code:
ball=0
def task1():
global ball
	while ball <4:
		yield viztask.waitEvent(viz.COLLIDE_BEGIN_EVENT)
		ball +=1
		
		print 'Number of Balls is : ',sball
In else where in the game function I am using the following line, the game function will quit the game if ball number is 4
Code:
balllob = viztask.waitTask( task1())
I guess I have to use the detection function, but I do not know how can I use it with many tasks relating to each other , as far as I realized Vizard’s documentation also dos not have this.
Thanks,
Reply With Quote