예제 #1
0
	def create_window(self):
		ltc.console_set_custom_font('fonts/' + self.user_settings['font'], ltc.FONT_TYPE_GREYSCALE | ltc.FONT_LAYOUT_TCOD)
		ltc.console_init_root(self.settings_screenSize[0], self.settings_screenSize[1], 'Robot Death Area', False)
		ltc.console_set_default_background(0,constants.colors['background'])
		ltc.sys_set_fps(self.settings_fpsLimit)
		# clears it so it will take the new default background color
		ltc.console_clear(0)

		self.creates_the_cons()
예제 #2
0
def main(world_info):
	if not network.multiplayer:
		barf.warn('Starting singleplayer game session.',False)
	global main_map
	screen_width	= parser.OPTIONS['game']['fullwidth']
	screen_height	= parser.OPTIONS['game']['fullheight']
	map_width		= parser.OPTIONS['game']['tilewidth']
	map_height		= parser.OPTIONS['game']['tileheight']
	root_width		= map_width
	root_height		= map_height

	tcod.sys_force_fullscreen_resolution(screen_width, screen_height)

	if parser.OPTIONS['game']['debug'] is True:
		barf.Barf('DBG', "'%s' v%s, by %s, loaded." % (world_info['name'], world_info['version'], world_info['author']))

	tcod.console_set_custom_font('data/tiles/terminal16x16_gs_as.png', tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_ASCII_INCOL)
	tcod.console_init_root(root_width, root_height, '%s v%s (%s)' % (version.__appname__, version.__version__, version.__edition__), False)

	tcod.sys_set_fps(12)

	# Set up initial consoles.
	console.update({
		'root'  : gui.Console(0, 0, screen_width, screen_height, 'Con', tcod.white, tcod.black),
		'map'   : gui.Console(0, 0, screen_width, screen_height, 'Map', tcod.white, tcod.BKGND_NONE),
		'chat'  : gui.Console(0, 0, screen_width, 8, 'Chat', tcod.white, tcod.BKGND_NONE),
		'health': gui.Console(0, 0, 22, 5, 'Health Meter', tcod.white, tcod.BKGND_NONE)
	})

	'''
	TODO: sync with server when network.multiplayer is True
	'''

	player = creature.Creature(console['map'].panel, 0, 0, 1, tcod.BKGND_NONE, [randrange(125,200),randrange(125,200),randrange(125,200)], name=getuser().capitalize()+str(randrange(1,100)))
	#npc    = creature.Creature(console['map'].panel, 0, 0, 1, tcod.BKGND_NONE, tcod.yellow, name='Naughty Non-Player')

	handler.handle_objects('add', {
		player.name: player
		#npc.name: npc
	})

	# Generate initial map

	#if not network.multiplayer:
	main_map = mapgen.Map(root_width, root_height)
	main_map = main_map.render_map(console['map'].panel)

	# Update creature locations to valid ones, if needed
	for obj in objects.values():
		obj.find_open(main_map, map_width, map_height)

	if network.multiplayer: network.client.Update(
		objects[player.name].name,
		(objects[player.name].x,objects[player.name].y),
		objects[player.name].char,
		objects[player.name]._color
		)

	# Build Health Meters
	bars.update({
		'mental'   : render.build_bar(root_width, root_height, 1, 1, 7, 10, 10, 'Mental', tcod.dark_green, tcod.desaturated_green),
		'physical' : render.build_bar(root_width, root_height, 1, 2, 7, 10, 10, 'Physical', tcod.crimson, tcod.desaturated_crimson),
		'spiritual': render.build_bar(root_width, root_height, 1, 3, 7, 10, 10, 'Spiritual', tcod.blue, tcod.desaturated_han),
	})

	mouse = tcod.Mouse()
	key = tcod.Key()

	while not tcod.console_is_window_closed():

		tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS|tcod.EVENT_MOUSE,key,mouse)

		if network.multiplayer: network.client.Loop()

		render.render_loop(console, objects, bars, root_width, root_height)

		exit = handler.handle_keys(player, main_map)
		if exit:
			break