本文整理汇总了Python中loader.Loader.set方法的典型用法代码示例。如果您正苦于以下问题:Python Loader.set方法的具体用法?Python Loader.set怎么用?Python Loader.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loader.Loader
的用法示例。
在下文中一共展示了Loader.set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import set [as 别名]
#.........这里部分代码省略.........
self.graphics.append([])
for j in range (0, self.width):
self.matrix[i].append(1)
self.graphics[i].append(randint(2, 4))
posX = self.height - 3
posY = self.width/2
self.matrix[posX][posY] = 0
moves = []
moves.append(posY + posX * self.width)
while len(moves) > 0:
possibleDirections = ""
if posX + 3 > 0 and posX + 3 < self.height - 1 and self.matrix[posX + 3][posY] == 1:
possibleDirections += 'S'
if posX - 3 > 0 and posX - 3 < self.height - 1 and self.matrix[posX - 3][posY] == 1:
possibleDirections += 'N'
if posY - 2 > 0 and posY - 2 < self.width - 1 and self.matrix[posX][posY - 2] == 1:
possibleDirections += 'W'
if posY + 2 > 0 and posY + 2 < self.width - 1 and self.matrix[posX][posY + 2] == 1:
possibleDirections += 'E'
if len(possibleDirections) > 0:
move = randint(0, len(possibleDirections) - 1)
if possibleDirections[move] == 'N':
self.matrix[posX - 3][posY] = 0
self.matrix[posX - 2][posY] = 0
self.matrix[posX - 1][posY] = 0
posX -= 3
elif possibleDirections[move] == 'S':
self.matrix[posX + 3][posY] = 0
self.matrix[posX + 2][posY] = 0
self.matrix[posX + 1][posY] = 0
posX += 3
elif possibleDirections[move] == 'W':
self.matrix[posX][posY - 2] = 0
self.matrix[posX][posY - 1] = 0
posY -= 2
elif possibleDirections[move] == 'E':
self.matrix[posX][posY + 2] = 0
self.matrix[posX][posY + 1] = 0
posY += 2
moves.append(posY + posX * self.width)
else:
back = moves.pop(-1)
posX = int(back / self.width)
posY = back % self.width
# erase lines (walls) in castle area and beginning area
for i in range (0, 11):
for j in range (1, self.width - 1):
_i = min(i, 1)
self.matrix[i][j] = 0
self.matrix[-_i - 2][j] = 0
# build graphics
for i in range (0, self.height - 1):
for j in range (0, self.width):
if self.matrix[i][j] == 1:
if self.matrix[i+1][j] == 1:
self.graphics[i][j] = CEMENT_TOP_WALL
else:
self.graphics[i][j] = CEMENT_BASE_WALL
# last line border
for j in range (0, self.width):
self.graphics[self.height - 1][j] = 1
# upper border
for j in range (1, self.width - 1):
self.matrix[6][j] = 1
self.matrix[6][0] = 0
self.matrix[6][-1] = 0
self.matrix[6][13] = 0
self.__draw()
Loader.set(self.image, 'maze')
self.matrix[7][2] = 1
self.matrix[7][3] = 1