parameters: ()
return_statement: return
docstring: Solves/builds the maze.
docstring_summary: Solves/builds the maze.
docstring_tokens: Solves / builds the maze .
function: def Update ():
  	""" Solves/builds the maze. """
  	global width, height, done, mx, my
  
  	done=True;															# // Set done To True
  	for x in xrange (0, width, 2):										# // Loop Through All The Rooms
  		for y in xrange (0, height, 2):									# // On X And Y Axis
  			if (tex_data[((x+(width*y))*3)]==0):						# // If Current Texture Pixel (Room) Is Blank
  				done=False;												# // We Have To Set done To False (Not Finished Yet)
  
  	if (done):															# // If done Is True Then There Were No Unvisited Rooms
  		# // Display A Message At The Top Of The Window, Pause For A Bit And Then Start Building A New Maze!
  		glutSetWindowTitle ("Lesson 42: Multiple Viewports... 2003 NeHe Productions... Maze Complete!");
  		time.sleep (5)
  		glutSetWindowTitle ("Lesson 42: Multiple Viewports... 2003 NeHe Productions... Building Maze!");
  		Reset();
  
  	# // Check To Make Sure We Are Not Trapped (Nowhere Else To Move)
  	if (((mx>(width-4) or tex_data[(((mx+2)+(width*my))*3)]==255)) and ((mx<2 or tex_data[(((mx-2)+(width*my))*3)]==255)) and
  		((my>(height-4) or tex_data[((mx+(width*(my+2)))*3)]==255)) and ((my<2 or tex_data[((mx+(width*(my-2)))*3)]==255))):
  		while True:												# // If We Are Trapped
  			mx = random.randint (0, (width/2) - 1) * 2				# // Pick A New Random X Position
  			my = random.randint (0, (height/2) - 1) * 2				# // Pick A New Random Y Position
  			if (tex_data[((mx+(width*my))*3)]==0):
  				break
  				# // Keep Picking A Random Position Until We Find
  				# // One That Has Already Been Tagged (Safe Starting Point)
  
  	dir = random.randint (0,3)									# // Pick A Random Direction
  
  	if ((dir==0) and (mx<=(width-4))):									# // If The Direction Is 0 (Right) And We Are Not At The Far Right
  		if (tex_data[(((mx+2)+(width*my))*3)]==0):						# // And If The Room To The Right Has Not Already Been Visited
  			UpdateTex(mx+1,my);											# // Update The Texture To Show Path Cut Out Between Rooms
  			mx+=2;														# // Move To The Right (Room To The Right)
  
  	if ((dir==1) and (my<=(height-4))):									# // If The Direction Is 1 (Down) And We Are Not At The Bottom
  		if (tex_data[((mx+(width*(my+2)))*3)]==0):						# // And If The Room Below Has Not Already Been Visited
  			UpdateTex(mx,my+1);											# // Update The Texture To Show Path Cut Out Between Rooms
  			my+=2;														# // Move Down (Room Below)
  
  	if ((dir==2) and (mx>=2)):											# // If The Direction Is 2 (Left) And We Are Not At The Far Left
  		if (tex_data[(((mx-2)+(width*my))*3)]==0):						# // And If The Room To The Left Has Not Already Been Visited
  			UpdateTex(mx-1,my);											# // Update The Texture To Show Path Cut Out Between Rooms
  			mx-=2;														# // Move To The Left (Room To The Left)
  
  	if ((dir==3) and (my>=2)):											# // If The Direction Is 3 (Up) And We Are Not At The Top
  		if (tex_data[((mx+(width*(my-2)))*3)]==0):						# // And If The Room Above Has Not Already Been Visited
  			UpdateTex(mx,my-1);											# // Update The Texture To Show Path Cut Out Between Rooms
  			my-=2;														# // Move Up (Room Above)
  
  	UpdateTex(mx,my);													# // Update Current Room
  	return
function_tokens: def Update ( ) : global width , height , done , mx , my done = True # // Set done To True for x in xrange ( 0 , width , 2 ) : # // Loop Through All The Rooms for y in xrange ( 0 , height , 2 ) : # // On X And Y Axis if ( tex_data [ ( ( x + ( width * y ) ) * 3 ) ] == 0 ) : # // If Current Texture Pixel (Room) Is Blank done = False # // We Have To Set done To False (Not Finished Yet) if ( done ) : # // If done Is True Then There Were No Unvisited Rooms # // Display A Message At The Top Of The Window, Pause For A Bit And Then Start Building A New Maze! glutSetWindowTitle ( "Lesson 42: Multiple Viewports... 2003 NeHe Productions... Maze Complete!" ) time . sleep ( 5 ) glutSetWindowTitle ( "Lesson 42: Multiple Viewports... 2003 NeHe Productions... Building Maze!" ) Reset ( ) # // Check To Make Sure We Are Not Trapped (Nowhere Else To Move) if ( ( ( mx > ( width - 4 ) or tex_data [ ( ( ( mx + 2 ) + ( width * my ) ) * 3 ) ] == 255 ) ) and ( ( mx < 2 or tex_data [ ( ( ( mx - 2 ) + ( width * my ) ) * 3 ) ] == 255 ) ) and ( ( my > ( height - 4 ) or tex_data [ ( ( mx + ( width * ( my + 2 ) ) ) * 3 ) ] == 255 ) ) and ( ( my < 2 or tex_data [ ( ( mx + ( width * ( my - 2 ) ) ) * 3 ) ] == 255 ) ) ) : while True : # // If We Are Trapped mx = random . randint ( 0 , ( width / 2 ) - 1 ) * 2 # // Pick A New Random X Position my = random . randint ( 0 , ( height / 2 ) - 1 ) * 2 # // Pick A New Random Y Position if ( tex_data [ ( ( mx + ( width * my ) ) * 3 ) ] == 0 ) : break # // Keep Picking A Random Position Until We Find # // One That Has Already Been Tagged (Safe Starting Point) dir = random . randint ( 0 , 3 ) # // Pick A Random Direction if ( ( dir == 0 ) and ( mx <= ( width - 4 ) ) ) : # // If The Direction Is 0 (Right) And We Are Not At The Far Right if ( tex_data [ ( ( ( mx + 2 ) + ( width * my ) ) * 3 ) ] == 0 ) : # // And If The Room To The Right Has Not Already Been Visited UpdateTex ( mx + 1 , my ) # // Update The Texture To Show Path Cut Out Between Rooms mx += 2 # // Move To The Right (Room To The Right) if ( ( dir == 1 ) and ( my <= ( height - 4 ) ) ) : # // If The Direction Is 1 (Down) And We Are Not At The Bottom if ( tex_data [ ( ( mx + ( width * ( my + 2 ) ) ) * 3 ) ] == 0 ) : # // And If The Room Below Has Not Already Been Visited UpdateTex ( mx , my + 1 ) # // Update The Texture To Show Path Cut Out Between Rooms my += 2 # // Move Down (Room Below) if ( ( dir == 2 ) and ( mx >= 2 ) ) : # // If The Direction Is 2 (Left) And We Are Not At The Far Left if ( tex_data [ ( ( ( mx - 2 ) + ( width * my ) ) * 3 ) ] == 0 ) : # // And If The Room To The Left Has Not Already Been Visited UpdateTex ( mx - 1 , my ) # // Update The Texture To Show Path Cut Out Between Rooms mx -= 2 # // Move To The Left (Room To The Left) if ( ( dir == 3 ) and ( my >= 2 ) ) : # // If The Direction Is 3 (Up) And We Are Not At The Top if ( tex_data [ ( ( mx + ( width * ( my - 2 ) ) ) * 3 ) ] == 0 ) : # // And If The Room Above Has Not Already Been Visited UpdateTex ( mx , my - 1 ) # // Update The Texture To Show Path Cut Out Between Rooms my -= 2 # // Move Up (Room Above) UpdateTex ( mx , my ) # // Update Current Room return