Example #1
0
def draw_maze(surface, maze):
    screen.fill(SCREEN_BLANK_COLOUR)
    render_grid(screen, maze,
                (SCREEN_W / 2) - (MAZE_W / 2),
                (SCREEN_H / 2) - (MAZE_H / 2),
                MAZE_W, MAZE_H,
                render_cell=draw_maze_cell)
Example #2
0
                if GRID_W > 1:
                    GRID_W -= 1
            elif event.key == K_UP:
                GRID_H += 1
            elif event.key == K_DOWN:
                if GRID_H > 1:
                    GRID_H -= 1

    random_cell = random.choice(world.items())
    if random_cell[1]:
        world[random_cell[0]] = 0
    else:
        world[random_cell[0]] = 1

    screen.fill((255, 255, 255))
    render_grid(screen, world,
                (SCREEN_W / 2) - (GRID_W / 2),
                (SCREEN_H / 2) - (GRID_H / 2),
                GRID_W, GRID_H,
                padding=GRID_PADDING)
    grid_w = font.render("GRID_W: %s" % GRID_W, True, FONT_COLOUR)
    grid_h = font.render("GRID_H: %s" % GRID_H, True, FONT_COLOUR)
    grid_pad = font.render("GRID_PADDING: %s" % GRID_PADDING, True, FONT_COLOUR)
    screen.blit(grid_w, (0, SCREEN_H - 40))
    screen.blit(grid_h, (0, SCREEN_H - 25))
    screen.blit(grid_pad, (0, SCREEN_H - 10))
    pygame.display.flip()


pygame.quit()