Beispiel #1
0
    def __init__(self, width, height, difficulty):
        self.DEBUG = False
        # initialize sizes and the grid representing our walls (or lack thereof)
        self.width = width
        self.height = height
        self.wallwidth = self.WIDTHS[difficulty]
        self.screen_offsets = ((constants.SCREEN_WIDTH - width) / 2,
                               (constants.SCREEN_HEIGHT - height) / 2)
        self.gridsize = (int(math.ceil(width / self.wallwidth)),
                         int(math.ceil(height / self.wallwidth)))
        # grid represents walls - True is a wall, left, top, right, down
        self.grid = [[[True, True, True, True] for y in range(self.gridsize[1])] for x in range(self.gridsize[0])]

        # configure some defaults for this specific maze
        self.wall_color = random_color()
        corners = ((0, 0), (0, self.gridsize[1] - 1), (self.gridsize[0] - 1, 0), (self.gridsize[0] - 1, self.gridsize[1] - 1))
        self.start = random.choice(corners)
        while True:
            self.end = random.choice(corners)
            if self.end != self.start:
                break
        # we will set this when generating the solution
        self.start_dir = None

        self.make_solution()

        self.player = Player(self.grid_to_screen(self.start), self.start_dir)
Beispiel #2
0
 def setup(self, first_time=False):
     # Selected menu choice - if "Continue" is there, have that selected
     self._current_option = NEW_GAME if first_time else CONTINUE
     self.game_running = self.manager.get_state('main', 'running')
     self.pipes = [Pipe(random_color()) for _ in range(NUM_PIPES)]
     self.overlay.set_alpha(225)