本文整理汇总了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"))
示例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"))