本文整理汇总了C++中Menu::MainMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::MainMenu方法的具体用法?C++ Menu::MainMenu怎么用?C++ Menu::MainMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::MainMenu方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void Game::Run() {
Player p1("Sergiy"), p2("Kostya");
Board b1("Board of Sergiy"), b2("Board of Kostya");
Menu m;
LOG(INFO, "Game::Run(): " <<"Player1 " << p1.GetName());
LOG(INFO, "Game::Run(): " <<"Player2 " << p2.GetName() << '\n');
COORDS c;
Player *pActivePlayer = &p1;
Board *bActiveBoard = &b2;
if (pActivePlayer->DecideWhoseHit()) {
cout << " Win :)" << endl;
cout << ' ' << p1.GetName() << " will hit first" << endl;
pActivePlayer = &p1;
bActiveBoard = &b2;
LOG(INFO,
"Game::Run(): " << pActivePlayer->GetName() << " wins, his hit first\n");
} else {
cout << " Loose :(" << endl;
cout << ' ' << p2.GetName() << " will hit first" << endl;
pActivePlayer = &p2;
bActiveBoard = &b1;
LOG(INFO,
"Game::Run(): " << pActivePlayer->GetName() << " wins, his hit first\n");
}
sleep(2);
clear();
p1.PlaceShips(b1);
p2.PlaceShips(b2);
b1.Print();
b2.Print();
while (b1.AnyAlive() && b2.AnyAlive()) {
c.x = pActivePlayer->InputCoordX(c);
c.y = pActivePlayer->InputCoordY(c);
if (!pActivePlayer->MakeTurn(*bActiveBoard, c)) {
bActiveBoard = (bActiveBoard == &b2 ? &b1 : &b2);
pActivePlayer = (pActivePlayer == &p1 ? &p2 : &p1);
}
sleep(1);
clear();
b1.Print();
b2.Print();
sleep(1);
}
LOG(INFO, " ");
if (!b1.AnyAlive()) {
cout << " Player " << p2.GetName() << " has won" << endl;
LOG(INFO,
"Game::Run(): "<< " Player " << p2.GetName() << " has won" << '\n');
} else {
cout << " Player " << p1.GetName() << " has won" << endl;
LOG(INFO,
"Game::Run(): "<< " Player " << p1.GetName() << " has won" << '\n');
}
sleep(1);
cout << " GAME OVER" << endl;
sleep(3);
m.MainMenu();
}
示例2: MainMenu
void Player::MainMenu() {
Menu m;
m.MainMenu();
}
示例3: 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;
}