示例#1
0
文件: game.py 项目: pom2ter/immortal
	def show_high_scores(self):
		if os.path.exists('highscores.dat'):
			IO.load_high_scores()
			contents = []
			for (score, line1, line2) in highscore:
				contents.append(str(score).ljust(6) + line1)
				contents.append('      ' + line2)
				contents.append(' ')
			messages.box('High scores', None, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, contents, input=False)
		else:
			contents = ['The high scores file is empty.']
			messages.box('High scores', None, 'center_screenx', 'center_screeny', len(max(contents, key=len)) + 16, len(contents) + 4, contents, input=False, align=libtcod.CENTER)
示例#2
0
文件: game.py 项目: pom2ter/immortal
	def new_game(self, chargeneration=True):
		global rnd, message, player, char, game_state, gametime, worldmap, current_map, savefiles
		cardinal = [-(WORLDMAP_WIDTH - 1), -(WORLDMAP_WIDTH), -(WORLDMAP_WIDTH + 1), -1, 1, WORLDMAP_WIDTH - 1, WORLDMAP_WIDTH, WORLDMAP_WIDTH + 1]
		rnd = libtcod.random_new()
		message = messages.Message()
		player = Player()
		char = mapgen.Object(libtcod.random_get_int(rnd, 40, 80), libtcod.random_get_int(rnd, 26, 46), player.icon, 'player', player.icon_color, blocks=True)
		if chargeneration:
			game_state = chargen.create_character()
		else:
			game_state = chargen.quick_start()
		if game_state == 'playing':
			contents = ['Generating world map...']
			messages.box(None, None, 'center_screenx', 'center_screeny', len(max(contents, key=len)) + 16, len(contents) + 4, contents, input=False, align=libtcod.CENTER, nokeypress=True)
			gametime = Time()
			worldmap = worldgen.World()
			current_map = mapgen.Map('Wilderness', 'WD', 0, (worldmap.player_positiony * WORLDMAP_WIDTH) + worldmap.player_positionx, type=util.find_terrain_type((worldmap.player_positiony * WORLDMAP_WIDTH) + worldmap.player_positionx))
			for i in range(len(border_maps)):
				border_maps[i] = mapgen.Map('Wilderness', 'WD', 0, (worldmap.player_positiony * WORLDMAP_WIDTH) + worldmap.player_positionx + cardinal[i], type=util.find_terrain_type((worldmap.player_positiony * WORLDMAP_WIDTH) + worldmap.player_positionx + cardinal[i]))
			IO.save_game(True)
			savefiles = [f for f in os.listdir('saves') if os.path.isfile(os.path.join('saves', f))]
			util.combine_maps()
			message.new('Welcome to Immortal, ' + player.name + '!', turns, libtcod.Color(96, 212, 238))
			self.play_game()
示例#3
0
文件: game.py 项目: pom2ter/immortal
	def main_menu(self):
		contents = ['Quick start', 'Start a new game', 'Load a saved game', 'Read the manual', 'Change settings', 'View high scores', 'Quit game']
		img = libtcod.image_load('title.png')
		libtcod.image_scale(img, int(SCREEN_WIDTH * 2.2), SCREEN_HEIGHT * 2)
		choice = 0

		while not libtcod.console_is_window_closed():
			libtcod.console_clear(0)
			libtcod.image_blit_2x(img, 0, 0, 0)
			libtcod.console_set_default_foreground(0, libtcod.light_yellow)
			libtcod.console_print_ex(0, 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.LEFT, 'Immortal ' + VERSION)
			libtcod.console_print_ex(0, SCREEN_WIDTH - 3, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, libtcod.RIGHT, 'Copyright (c) 2012-13 -- Mr.Potatoman')
			libtcod.console_print_ex(0, SCREEN_WIDTH - 5, SCREEN_HEIGHT - 22, libtcod.BKGND_NONE, libtcod.RIGHT, 'Main Menu')
			if choice == -1:
				choice = 0
			choice = messages.box(None, None, (SCREEN_WIDTH - len(max(contents, key=len)) - 6), ((SCREEN_HEIGHT + 4) - len(contents)) / 2, len(max(contents, key=len)) + 5, len(contents) + 2, contents, choice, color=None, align=libtcod.RIGHT, scrollbar=False)

			if choice == 0:  # quick start
				self.new_game(False)
				self.reset_game()
			if choice == 1:  # start new game
				self.new_game()
				self.reset_game()
#				test.worldgentest(50)
			if choice == 2:  # load saved game
				start = IO.load_game()
				if start:
					self.play_game()
				self.reset_game()
			if choice == 3:  # help
				self.help()
			if choice == 4:  # settings
				self.settings()
			if choice == 5:  # high scores
				self.show_high_scores()
			if choice == 6:  # quit
				for fade in range(255, 0, -8):
					libtcod.console_set_fade(fade, libtcod.black)
					libtcod.console_flush()
				break
示例#4
0
文件: game.py 项目: pom2ter/immortal
	def help(self):
		contents = IO.load_manual()
		messages.box('Help', None, 'center_screenx', 'center_screeny', len(max(contents, key=len)) + 16, len(contents) + 4, contents, input=False)