-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (44 loc) · 1.27 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*********************************************************************
** Program name: main.cpp
** Author: Jesse McKenna
** Date: 11/19/2017
** Description: Runs the game contained in game.hpp until the player chooses to
** quit
*********************************************************************/
#include "game.hpp"
#include "menu.hpp"
#include "getInput.hpp"
#include <iostream>
int main()
{
// Introduction
std::cout
<< " mm mm mm\n"
<< " /^( )^\\ /^( )^\\ /^( )^\\\n"
<< " \\,(..),/ \\,(..),/ \\,(..),/\n"
<< " V~~V V~~V V~~V\n" // from http://chris.com/ascii/index.php?art=animals/bats
<< "\n--- Welcome to Cave Escape! ---\n";
// Main menu
Menu mainMenu(2);
mainMenu.setPrompt(1, "Play");
mainMenu.setPrompt(2, "Exit");
int mainChoice = mainMenu.showMenu();
if (mainChoice == 2)
{
return 0;
}
// Game setup
Menu replayMenu(2); // play again menu displayed after round end
replayMenu.setPrompt(1, "Play again");
replayMenu.setPrompt(2, "Quit");
int replayChoice;
Game game;
// Game loop
do
{
game.play();
// Ask if player wants to play again
replayChoice = replayMenu.showMenu();
} while (replayChoice == 1); // repeat game until player chooses to quit
return 0;
}