-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
62 lines (49 loc) · 1.78 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
54
55
56
57
58
59
60
61
62
/*********************************************************************
* Program Name: Valley of the Moon
* Author: Patrick Rice
* Date: 12/5/2017
* Description: A text based adventure game, that uses the keyboard
* to move around. The character must collect a set of keys in order
* to reach the end of the game. The number of steps the character
* has left, is the limit to the length of the game.
*********************************************************************/
#include "utils/menu.hpp"
#include "maps/map.hpp"
#include "utils/utilities.hpp"
#include "gamePlay.hpp"
using std::cout;
using std::endl;
int main() {
// rand() function needs to be seeded only one time. Seeding
// happens here so that it is only called once.
unsigned seed;
seed = static_cast<unsigned int>(time(nullptr));
srand(seed);
int width = 90, mainMenuChoice = 0;
system("clear");
printBoldCenterTitle("Valley of the Moon", width);
printCenteredString("A text-based adventure game", width);
printCenteredString("Please adjust your console to fit this dialogue", width);
printBorder(width);
Menu mainMeu("Would you like to play the game?");
mainMeu.addOption("Play");
mainMeu.addOption("Exit");
Menu playAgain("Would you like to play again?");
playAgain.addOption("Yes");
playAgain.addOption("No");
mainMeu.printMenu();
mainMenuChoice = mainMeu.getChoice();
if (mainMenuChoice != 2) {
do {
if (mainMenuChoice == 1) {
// play the game
GamePlay gameState;
gameState.play();
playAgain.printMenu();
mainMenuChoice = playAgain.getChoice();
}
} while (mainMenuChoice != 2);
}
printMessage("Goodbye",width);
return 0;
}