View Single Post
  #1  
Old 07-15-2009, 08:06 PM
jaylocco jaylocco is offline
Member
 
Join Date: Jun 2009
Posts: 19
Question Python Programming Question

Im sory to ask this because Im still new to Python. but is there such a thing as 'nested While' in Python just like in C++? Im trying to loop a vizard game which contain a 'while true:' loop. the thing is, how do I repeat the whole program. this is the sample programming code.

Code:
    def game()
        
        yield viztask.waitKeyDown(' ') #<----starts the game
	#fade intro page
	fadeOut = vizact.fadeTo(0,begin=1,time=1)
	startpage.addAction(fadeOut)
	#call throwing function
	throwing ()
	viz.phys.setGravity(0,0,0)

        while True: # this while loop will repeat the flying Aliens to and fro
		FlyAliens() #flies the Aa Bb Cc Aliens
                ResetPositionAliens()     
     myTask = viztask.schedule( game() )

Aliens= [Aa,Bb,Cc]
Ship.enable(viz.COLLIDE_NOTIFY)
		
def oncollide (e) :	
	
	if e.obj2 in Aliens:

		Ship.visible(viz.OFF)
		Shipcrash.visible(viz.ON)
		view.lookat([2,0,-5])
               

viz.callback(viz.COLLIDE_BEGIN_EVENT,oncollide)
Let say if the ship collide with any of the aliens, the ship will crashes down and it will prompt user whether to replay again or not.

So how do we reset the game by using another while loop by pressing the 'r' button ( yield viztask.waitKeyDown('r') ) and back to the beginning. (#<----starts the game)

tq

Last edited by jaylocco; 07-15-2009 at 08:16 PM.
Reply With Quote