Пример #1
0
	def __init__ (self, width, height, seed = None):
		"""	Initialise the map """
		self.width, self.height = width, height
		self.console = libtcod.console_new(width, height)

		# Setup logging and log the type of map being created
		self.log = getlog(str(self.__class__))
		self.log.info("Generating a {}".format(self.__class__.__name__))

		# Setup rng
		RngTrait.__init__(self, seed)

		# Setup tiles and fill with None
		self.tiles = [ [ None for x in range(self.height) ] for y in range(self.width) ]

		# Setup objects list
		self.objects = []

		# Default spawn point
		self.spawn = (1,1)
Пример #2
0
	def __init__ (self):
		""" Initialise the game """
		# Setup logging
		self.log = getlog(self.__class__.__name__)

		# Console size
		self.width = 80
		self.height = 50

		# libtcod initialization
		libtcod.console_set_custom_font('consolas10x10_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
		libtcod.console_init_root(self.width, self.height, 'Darkness', False)

		# Command initialization
		self.commands = {
			# Commands that do not cause the player to take a turn
			libtcod.KEY_ESCAPE: lambda self: self.stop(),
		}
		self.ingame_commands = {
			# Commands that are a player turn
			libtcod.KEY_UP:		lambda self: self.player.move(dy = -1),
			libtcod.KEY_DOWN:	lambda self: self.player.move(dy = +1),
			libtcod.KEY_LEFT:	lambda self: self.player.move(dx = -1),
			libtcod.KEY_RIGHT:	lambda self: self.player.move(dx = +1),
		}

		# Select options
		self.options = {
			'fov_torch_radius': 6,
			'fov_light_walls': True,
		}

		# Create player
		self.player = Player()

		# Load map
		map_type, map_args = RandomDungeon, ()
		self.load_map(map_type, *map_args)