def mainLoop():
	maze = WilsonsAlgorithm.generate_maze(width, height)
	WilsonsAlgorithm.print_maze(maze)
	exiting = False
	tiles = loadTiles()
	lines = loadLines()
	x, y = 0, 0
	path = []
	while not exiting:
		#screen.fill(BACKGROUND)
		display_maze(maze, tiles)
		events = pygame.event.get()
		path, x, y = get_key_input(path,x,y,maze,events)
		display_path(path, lines)
		pygame.display.flip()
		print x, y
		if x == width-1 and y == height-1:
			print "exiting"
			wintext = pygame.image.load("./maze-tiles/wintext.png")
			print 374.0/(width*scale)
			wintext = pygame.transform.scale(wintext, (width*scale, int(height*scale*((width*scale)/374.0))))
			screen.blit(wintext, (0,(height-int(height*((width*scale)/374.0)))/2))
			pygame.display.flip()
			sleep(3)
			break
		exiting = checkExit(events)
示例#2
0
 def __init__(self):
   super(MazeGUI, self).__init__()
   self.FILEPATH = "/".join(__file__.split("/")[:-1])
   self.width = 4
   self.height = 4
   self.scale = 100
   self.N, self.S, self.E, self.W = 1, 2, 4, 8 # Flags for encoding connection
   self.DX =       {self.E:1,      self.W:-1,     self.N:0,      self.S:0}
   self.DY =       {self.E:0,      self.W:0,      self.N:-1,     self.S:1}
   self.OPPOSITE = {self.E:self.W, self.W:self.E, self.N:self.S, self.S:self.N}
   self.screen = pygame.display.set_mode((self.width*self.scale, self.height*self.scale))
   self.maze = WilsonsAlgorithm.generate_maze(self.width, self.height)
   # WilsonsAlgorithm.print_maze(self.maze)
   self.exiting = False
   self.tiles = self.loadTiles()
   self.lines = self.loadLines()
   self.path = []
   self.playerx = 0
   self.playery = 0