本文整理汇总了Python中dungeon.Dungeon.load_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Dungeon.load_from_file方法的具体用法?Python Dungeon.load_from_file怎么用?Python Dungeon.load_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dungeon.Dungeon
的用法示例。
在下文中一共展示了Dungeon.load_from_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import load_from_file [as 别名]
def main():
"""
Quick game setup for testing purposes.
"""
win = pygcurse.PygcurseWindow(80, 30)
win.font = pygame.font.Font(pygame.font.match_font("consolas"), 18)
level1 = Dungeon.load_from_file("map/bigmap.txt")
player = Player(1, 1)
level1.add_player(player)
msgbox = MessageBox()
view = GameView(
win, {ScrollingView(level1): (0, 0), HUDView(player): (700, 0), MessageBoxView(msgbox, 80, 5): (0, 460)}
)
controller = Controller(level1, msgbox, view)
win.autoupdate = False
mainClock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
running = False
else:
controller.process_event(event)
controller.view.draw()
win.blittowindow()
mainClock.tick(30)
pygame.quit()
sys.exit()
示例2: DungeonView
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import load_from_file [as 别名]
direction_y -= 1
elif event.type == KEYDOWN and event.key == K_DOWN:
direction_y += 1
#elif event.type == KEYDOWN and event.key == K_p:
#print(self.dungeon.get_field_of_vision(self.dungeon.player.x, self.dungeon.player.y, 5))
old_x, old_y = self.dungeon.player.x, self.dungeon.player.y
self.dungeon.player.x += direction_x
self.dungeon.player.y += direction_y
if self.dungeon.collide(*self.dungeon.player.pos):
self.dungeon.player.x, self.dungeon.player.y = old_x, old_y
else:
self.dungeon.reveal(self.dungeon.player.x, self.dungeon.player.y, 5)
if __name__ == '__main__':
win = pygcurse.PygcurseWindow(40, 20)
level1 = Dungeon.load_from_file('map/map.txt')
level1.add_player(Player(1, 1))
view = DungeonView(level1, win)
controller = Controller(level1, view)
win.autoupdate = False
mainClock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
controller.process_event(event)
win.setscreencolors()
win.cursor = (0,0)
view.draw()
win.update()
示例3: __init__
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import load_from_file [as 别名]
def __init__(self, dungeon, win):
self.dungeon = dungeon
self.win = win
self.win.font = pygame.font.Font('C:\Windows\Fonts\Consola.ttf', 22)
def draw(self):
"Draw the dungeon and the player."
for line in self.dungeon:
for tile in line:
if tile.visible:
self.win.write(tile.value, bgcolor=(30, 30, 30))
else:
self.win.write(' ')
self.win.write('\n')
for light_x, light_y in self.dungeon.get_field_of_vision(self.dungeon.player.x, self.dungeon.player.y, 5):
if not self.dungeon[light_x, light_y].block_light:
self.win.settint(100, 100, 0, (light_x, light_y, 1, 1))
self.win.putchar(PLAYER, x=self.dungeon.player.x, y=self.dungeon.player.y)
if __name__ == '__main__':
import dungeon, player
win = pygcurse.PygcurseWindow(40,30)
level1 = Dungeon.load_from_file('../test/map.txt')
level1.add_player(player.Player(1, 1))
view = DungeonView(level1, win)
view.draw()
pygcurse.waitforkeypress()