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


C++ FileIO::ReadSavedData方法代码示例

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


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

示例1: UsingTitle

void GameController::UsingTitle()
{
	//Press W,S to select the menuitem.
	//Press J to use the menuitem.
	SetPosition(62, 20);
	cout << "  " << flush;


	switch (hitkey)
	{
	case TITLE_MENU_UP: {//Move the '->' up.
		if (Scene.GetTitleCursorPositionY() >= 16)
		{
			SetPosition(Scene.GetTitleCursorPositionX(), Scene.GetTitleCursorPositionY());
			cout << "  " << flush;
			Scene.SetTitleCursorPositionY(Scene.GetTitleCursorPositionY() - 2);
		}; break;
	}
	case TITLE_MENU_DOWN: {//Move the '->' down.
		if (Scene.GetTitleCursorPositionY() <= 18)
		{
			SetPosition(Scene.GetTitleCursorPositionX(), Scene.GetTitleCursorPositionY());
			cout << "  " << flush;
			Scene.SetTitleCursorPositionY(Scene.GetTitleCursorPositionY() + 2);
		}; break;
	}
	case TITLE_MENU_PRESS: {
		switch (Scene.GetTitleCursorPositionY())
		{
		case 14: {
			Scene.TitleClear();
			game_start = true;
		}; break;
		case 16: {
			Scene.DrawSelectSavedDataArea();
			SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
			cout << "->" << flush;
			//The followings are the operations of reading the saved data.
			while (1)
			{
				if (_kbhit())
				{
					hitkey = _getch();
					if (hitkey == 'k')
					{
						Scene.SelectSavedDataAreaClear();
						break;
					}

					switch (tolower(hitkey))
					{
					case TITLE_MENU_UP: {
						if (Scene.GetSavedDataCursorPositionY() >= 12)
						{
							SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
							cout << "  " << flush;
							Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() - 1);
						}
					}break;
					case TITLE_MENU_DOWN: {
						if (Scene.GetSavedDataCursorPositionY() <= 19)
						{
							SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
							cout << "  " << flush;
							Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() + 1);
						}
					}break;
					case TITLE_MENU_PRESS: {
						//The class FileIO will start to work here.
						switch (Scene.GetSavedDataCursorPositionY())//The cursor's y position will decide which data to be changed.
						{
						case 11: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata1.txt"); //Then the important information in the game will be initialized.

						}break;
						case 12: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata2.txt");
						}break;
						case 13: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata3.txt");
						}break;
						case 14: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata4.txt");
						}break;
						case 15: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata5.txt");
						}break;
						case 16: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata6.txt");
						}break;
						case 17: {
							FileIO fileIO;
							fileIO.ReadSavedData("saveddata7.txt");
						}break;
//.........这里部分代码省略.........
开发者ID:StarsGazer,项目名称:learngit,代码行数:101,代码来源:GameController.cpp

示例2: UsingMenu


//.........这里部分代码省略.........
				if (_kbhit())
				{
					hitkey = _getch();
					if (hitkey == 'k')
					{
						Scene.SelectSavedDataAreaClear();
						Scene.RedrawCharaters();
						break;
					}

					switch (hitkey)
					{
					case MENU_UP: {
						if (Scene.GetSavedDataCursorPositionY() >= 12)
						{
							SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
							cout << "  " << flush;
							Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() - 1);
						}
					}break;
					case MENU_DOWN: {
						if (Scene.GetSavedDataCursorPositionY() <= 19)
						{
							SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
							cout << "  " << flush;
							Scene.SetSavedDataCursorPositionY(Scene.GetSavedDataCursorPositionY() + 1);
						}
					}break;
					case MENU_PRESS: {
						//The class FileIO will start to work here.
						switch (Scene.GetSavedDataCursorPositionY())//The cursor's y position will decide which data to be changed.
						{
						case 11: {			
							fileIO.ReadSavedData("saveddata1.txt"); //Then the important information in the game will be initialized.
						}break;
						case 12: {
							fileIO.ReadSavedData("saveddata2.txt");
						}break;
						case 13: {
							fileIO.ReadSavedData("saveddata3.txt");
						}break;
						case 14: {
							fileIO.ReadSavedData("saveddata4.txt");
						}break;
						case 15: {
							fileIO.ReadSavedData("saveddata5.txt");
						}break;
						case 16: {
							fileIO.ReadSavedData("saveddata6.txt");
						}break;
						case 17: {
							fileIO.ReadSavedData("saveddata7.txt");
						}break;
						case 18: {
							fileIO.ReadSavedData("saveddata8.txt");
						}break;
						case 19: {
							fileIO.ReadSavedData("saveddata9.txt");
						}break;
						case 20: {
							fileIO.ReadSavedData("saveddata10.txt");
						}break;
						}
					}break;
					}
					SetPosition(Scene.GetSavedDataCursorPositionX(), Scene.GetSavedDataCursorPositionY());
开发者ID:StarsGazer,项目名称:learngit,代码行数:67,代码来源:GameController.cpp


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