当前位置: 首页>>代码示例>>Python>>正文


Python Screen.width方法代码示例

本文整理汇总了Python中screen.Screen.width方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.width方法的具体用法?Python Screen.width怎么用?Python Screen.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在screen.Screen的用法示例。


在下文中一共展示了Screen.width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: range

# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import width [as 别名]

screen_grid = []

for i in range((HEIGHT * 2) + 1):
    screen_grid.append([])
    for j in range((WIDTH * 2) + 1):
        screen_grid[i].append("")

for i in range(HEIGHT):
    for j in range(WIDTH):
        y = i * 2 + 1
        x = j * 2 + 1
        cell = grid[i][j]
        screen_grid[y - 1][x] = cell.up
        screen_grid[y + 1][x] = cell.down
        screen_grid[y][x - 1] = cell.left
        screen_grid[y][x + 1] = cell.right
        screen_grid[y - 1][x - 1] = "WALL"
        screen_grid[y - 1][x + 1] = "WALL"
        screen_grid[y + 1][x - 1] = "WALL"
        screen_grid[y + 1][x + 1] = "WALL"
        screen_grid[y][x] = "EMPTY"

screen = Screen()
screen.grid = screen_grid
screen.height = HEIGHT * 2 + 1
screen.width = WIDTH * 2 + 1

pickle.dump(screen, open("grids/gen_maze.p", "wb"))
开发者ID:dcravenus,项目名称:ascii_game,代码行数:31,代码来源:gen_maze.py

示例2: Screen

# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import width [as 别名]
screen = Screen()

for filename in glob.glob(os.path.join(path, '*.grid')):
    grid = []
    print("Pickling " + filename)
    with open(filename, 'r') as f:
        for line in f:
            row = []
            for char in line:
                if char == WALL_CHAR:
                    row.append("WALL")
                elif char == PLAYER_CHAR:
                    row.append("PLAYER")
                elif char == EMPTY_CHAR:
                    row.append("EMPTY")
                elif char == "\n" or char == " ":
                    pass
                else:
                    print("Unrecognized character: " + char)
            grid.append(row)


    screen.height = len(grid)
    screen.width = len(grid[0])
    screen.grid = grid

    new_filename = os.path.splitext(filename)[0] + ".p"
    print("Creating pickle " + new_filename)
    pickle.dump(screen, open(new_filename, "wb"))
开发者ID:dcravenus,项目名称:ascii_game,代码行数:31,代码来源:pickler.py


注:本文中的screen.Screen.width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。