def __init__(self, map_path): #fix init to a set size, and edge in with clouds self.level = int(map_path[len(map_path)-1:]) self.dummy = False self.map_path = map_path self.names = None if self.level == 5: self.initBinary() #TODO randomized Binary search stuff elif self.level == 6: maze.create_maze() #TODO drunken walk stuff #sets the plane self.filetomap(map_path) if self.level == 6: self.hood() found = False self.plane = Airplane(self) for y in xrange(self.height): for x in xrange(self.width): if(self.grid[y][x].getType()=="PLANE"): found = True self.py = y self.px = x if self.level == 6: found = True self.py = 0 self.px = 0 if found == False: raise NoPlaneException() #there wasn't a plane
def __init__(self, root, mw, username): Frame.__init__(self, root, background="MediumTurquoise") self.parent = root self.mw = mw self.username = username self.levelFilename = "../support/levels/level" self.stencilFilename = "../support/stencil/level" self.helpFilename = "../support/help/level" self.canRun = False self.endStatus = False # change font size depending on screen dimension screen_width = self.parent.winfo_screenwidth() screen_height = self.parent.winfo_screenheight() # projector setting if screen_width == 1280: self.customFont1 = tkFont.Font(family="Pupcat", size=18, weight=tkFont.BOLD) self.customFont2 = tkFont.Font(family="LMMono10", size=17) self.boldFont = tkFont.Font(family="LMMono10", size=17, weight=tkFont.BOLD) self.italFont = tkFont.Font(family="LMMono10", size=17, slant=tkFont.ITALIC) # single screen setting elif screen_width == 1920: self.customFont1 = tkFont.Font(family="Pupcat", size=14, weight=tkFont.BOLD) self.customFont2 = tkFont.Font(family="LMMono10", size=14) self.boldFont = tkFont.Font(family="LMMono10", size=14, weight=tkFont.BOLD) self.italFont = tkFont.Font(family="LMMono10", size=14, slant=tkFont.ITALIC) # double screen setting else: self.customFont1 = tkFont.Font(family="Pupcat", size=14, weight=tkFont.BOLD) self.customFont2 = tkFont.Font(family="LMMono10", size=15) self.boldFont = tkFont.Font(family="LMMono10", size=14, weight=tkFont.BOLD) self.italFont = tkFont.Font(family="LMMono10", size=14, slant=tkFont.ITALIC) self.initToolbar() self.initCanvas() self.initTextBoxes() self.initUI() self.currLevel = 1 self.beatenLevels = [] self.initLevelCanvas() self.initLevelText() maze.create_maze()
def runLevelDummy(self, user_name): working = runBox.run(self.map_path, self.level, user_name) #working = self.sand.start(self.map_path) output = open("output.py","r") if working: if self.level == 6: maze.create_maze() self.filetomap(self.map_path) self.hood() self.py=0 self.px=0 elif self.level == 5: self.initBinary() import runLevel as run reload(run) for y in xrange(self.height): for x in xrange(self.width): if(self.grid[y][x].getType()=="PLANE"): self.py = y self.px = x #establish the path to pass along to GUI self.dummy = True self.plane.setDummy(True) self.plane.setHeading(0) try: run.runLevel(self.plane) except CrashException: pass; #do nothing, these are just to keep the user #code from executing forever self.dummy = False self.plane.setDummy(False) # else: #display error message?? #TODO get this working? return working;
from pygame import image, Surface from img import load_tiles, get_tiles_rect, SIZE from maze import create_maze def parse_grid(data): return data.strip().split('\n') def draw_grid(data, tile_img, tiles): xs = len(data[0]) * SIZE ys = len(data) * SIZE img = Surface((xs, ys)) for y, row in enumerate(data): for x, char in enumerate(row): rect = get_tiles_rect(x, y) img.blit(tile_img, rect, tiles[char]) return img if __name__ == '__main__': tile_img, tiles = load_tiles() level = create_maze(12, 7) level = parse_grid(level) maze = draw_grid(level, tile_img, tiles) image.save(maze, 'dist/maze.png')