本文整理汇总了Python中dungeon.Dungeon.generate方法的典型用法代码示例。如果您正苦于以下问题:Python Dungeon.generate方法的具体用法?Python Dungeon.generate怎么用?Python Dungeon.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dungeon.Dungeon
的用法示例。
在下文中一共展示了Dungeon.generate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import generate [as 别名]
class Game:
def __init__(self):
self.screen = create_screen()
self.tmp_dungeon = Dungeon(80, 20)
self.tmp_dungeon.generate()
self.dungeons = [self.tmp_dungeon]
self.player = Player(*self.dungeons[0].up_stair)
def play(self):
self.screen.get_key()
self.screen.draw_dungeon(self.dungeons[self.player.floor - 1], self.player)
self.screen.push_message('Welcome to Necronomicon, my first roguelike...')
while True: # Main game loop
char = self.screen.get_key()
if char == 'q': # Quit game
quit = self.screen.ask_message('Do you really want to quit?')
if quit.lower() in ['y', 'yes', 'yea']:
break
elif char == '?': # Show help
self.screen.push_message('This is a fantastic game... :)')
elif char in ['h', 'j', 'k', 'l', 'y', 'u', 'b', 'n', '.']: # Movement
success = self.player.move(char, self.dungeons[self.player.floor - 1])
if success:
self.screen.draw_dungeon(self.dungeons[self.player.floor - 1], self.player)
self.screen.update_info(self.player)
else:
self.screen.push_message('You can\'t go on this way')
elif char == '>':
if self.dungeons[self.player.floor - 1].cell(self.player.x, self.player.y).char == '>':
self.dungeons.append(Dungeon(80, 20))
self.player.floor += 1
self.dungeons[self.player.floor - 1].generate()
self.player.moves += 1
self.screen.update_info(self.player)
self.player.x, self.player.y = self.dungeons[self.player.floor - 1].up_stair
self.screen.draw_dungeon(self.dungeons[self.player.floor - 1], self.player)
self.screen.push_message('Welcome to the %d floor' % self.player.floor)
else:
self.screen.push_message('There isn\'t down stairs here')
elif char == '<':
if self.dungeons[self.player.floor - 1].cell(self.player.x, self.player.y).char == '<':
if self.player.floor == 1:
self.screen.push_message('You can\'t escape from the dungeon')
else:
self.player.floor -= 1
self.player.moves += 1
self.player.x, self.player.y = self.dungeons[self.player.floor - 1].down_stair
self.screen.push_message('You returned at the %d dungeon' % self.player.floor)
self.screen.update_info(self.player)
self.screen.draw_dungeon(self.dungeons[self.player.floor - 1], self.player)
else:
self.screen.push_message('There isn\'up stairs here')
示例2: Vec
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import generate [as 别名]
cfg.min_levels = cfg.max_levels = d[5]
cfg.offset = '%d %d %d' % (d[6], d[7], d[8])
args.entrance = [d[4]['entrance_pos'].x, d[4]['entrance_pos'].z]
args.entrance_height = d[4]['entrance_height']
cfg.portal_exit = d[4].get('portal_exit', Vec(0, 0, 0))
cfg.dungeon_name = d[4].get('dungeon_name', ruins.Blank.nameDungeon())
print 'Regenerating dungeon at', cfg.offset, '...'
dungeon = Dungeon(args,
world,
oworld,
chunk_cache,
dungeon_cache,
good_chunks,
map_store)
result = dungeon.generate(cache_path, __version__)
if result is False:
print 'Failed to regenerate dungeon! Aborting!'
sys.ext(1)
sys.exit()
# Validate size settings
cfg.min_x = 4
cfg.max_x = cfg.max_dist - cfg.min_dist
cfg.min_z = 4
cfg.max_z = cfg.max_dist - cfg.min_dist
cfg.min_levels = 1
cfg.max_levels = 8
# Range for X
示例3: Player
# 需要导入模块: from dungeon import Dungeon [as 别名]
# 或者: from dungeon.Dungeon import generate [as 别名]
import os
from entity import Player, Monster
from dungeon import Dungeon
from actions import Moves
player = Player()
monster = Monster()
dungeon = Dungeon()
moves = Moves()
dungeon.generate()
player.set_location(0, 0)
monster.set_location(2, 2)
all_entities = [player, monster]
while True:
if player.location == monster.location:
print "The monster ate you!"
break
dungeon.get(all_entities)
moves.invalid_moves(player, dungeon)
direction = raw_input(">> Where would you like to move?\n").upper()
if direction == "QUIT":
break
moves.move(player, direction)
moves.reset()
os.system('cls' if os.name == 'nt' else 'clear')