当前位置: 首页>>代码示例>>C++>>正文


C++ Files::ReadSavedGame方法代码示例

本文整理汇总了C++中Files::ReadSavedGame方法的典型用法代码示例。如果您正苦于以下问题:C++ Files::ReadSavedGame方法的具体用法?C++ Files::ReadSavedGame怎么用?C++ Files::ReadSavedGame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Files的用法示例。


在下文中一共展示了Files::ReadSavedGame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

//The Game
int main(int argc, char* args[]) {

	Food Food;
	GraphicFiles_Vars GF_Var;
	InternalRandom IRand;
	LoopControl Loop;
	OptionsRandom ORand;
	Map Map;
	MidVars MidVar;
	Snake Snake;
	Timer Timer;

	GMI_Vars GMI_Var;

	Files File;
	FoodSys FoodSys;
	GameOver GameOver;
	GraphicFiles_Main GF_Main;
	Initializers Init;
	Input Input;
	Menu Menu;
	NPC NPC;
	Tail Tail;

	//External variables initializers.
	Init.ExternalVariableInitializers(Food, GMI_Var, IRand, Loop, Map, ORand, Snake);
	//Gets saved options from a txt file.
	File.ReadOptionsFile(IRand, Map, MidVar, ORand, Snake);
	//Gets high scores from a txt file.
	File.ReadHighScoresFile(IRand, MidVar);
	//Initializes SDL
	GF_Main.init_SDL(GMI_Var, GF_Var);
	//Gets snake movement controls from a txt file.
	File.ReadInputASCII(GF_Var, MidVar);
	//The program (re)start point.
	while (Loop.getGameReset()) {
		//Menu, where the user can customize and start the game.
		Menu.MainMenu(GMI_Var, GF_Var, IRand, Loop, Map, MidVar, ORand);
		//Saves Options to a txt file.
		File.WriteOptionsFile(Map, ORand, Snake);
		//Saves snake movement controls to a txt file.
		File.WriteInputASCII(GF_Var);
		if (Loop.getGameReset()) {
			//Initializes SDL components for the game loop.
			GF_Main.init_SDL_GameLoop(GMI_Var, GF_Var, Map, ORand);
			//Reads saved game txt file if game is loaded.
			File.ReadSavedGame(Food, IRand, Map, MidVar, ORand, Snake);
			//Defaults variables for the game loop.
			Init.InternalVariableInitializers(Food, GMI_Var, GF_Var, IRand, Loop, Map, ORand, Snake);
			//Constructes the borders of the map.
			Init.MapBorderBuild(IRand, Map);
			//Initializers for the game loop.
			Init.FunctionInitializers(Food, IRand, Map, ORand, Snake, Timer);
			//The game loop.
			while (!Loop.getExitState()) {
				//SDL based input system.
				Input.GetInput(GMI_Var, GF_Var, IRand, Loop, Map, ORand, Snake, Timer);
				//Saves game on exit if user chooses to.
				File.WriteSavedGame(Food, IRand, Loop, Map, ORand, Snake);
				//NPC AI
				NPC.NPC_Move(Food, Map, ORand, Snake);
				//Checks user input.
				Tail.ProcessUserInput(IRand, Loop, Map, ORand, Snake);
				//Deletes the snake right after death.
				Tail.DeleteSnakeTail(IRand, Map, ORand, Snake);
				//Places the food onto the map and processes it.
				FoodSys.FoodProcess(Food, GF_Var, IRand, Loop, Map, ORand, Snake);
				//Keeps the tail of the Snake the same size (becomes larger as you eat).
				Tail.TailLengthMaintainer(IRand, Map, ORand, Snake);
				//Draws the SDL game loop screen.
				GF_Main.UpdateGameScreen(GMI_Var, GF_Var, Food, Loop, Map, ORand, Snake);
				//Exits the game loop if a right condition is met.
				GameOver.GameLoopExit(IRand, Loop, Map, ORand, Snake);
			}
			GF_Main.quit_SDL_GameLoop(GF_Var);
		}
		//Saves high scores to a txt file.
		File.WriteHighScoresFile(IRand, Loop, MidVar, ORand);
		//Tells you how you exited the game loop and shows final score(s).
		GameOver.GameOverMessage(GMI_Var, GF_Var, IRand, Loop, Map, ORand);
	}
	//Quits SDL
	GF_Main.quit_SDL(GF_Var, ORand);

	return 0;
}
开发者ID:TakingItCasual,项目名称:Snakes,代码行数:87,代码来源:main.cpp


注:本文中的Files::ReadSavedGame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。