-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAzul.cpp
More file actions
executable file
·64 lines (62 loc) · 1.7 KB
/
Azul.cpp
File metadata and controls
executable file
·64 lines (62 loc) · 1.7 KB
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
63
64
#include "GameEngine.h"
#include "Saver.h"
#include "Menu.h"
#include "Saver.h"
int main(int argc, char const *argv[])
{
//GameEngine engine = new GameEngine();
Menu menu;
bool exit = false;
std::string input;
GameEngine *engine = nullptr;
Saver saver;
do
{
menu.printMenu();
input = menu.getInput();
if (input == "1")
{
menu.printMessage("Starting a New Game");
engine = new GameEngine(&menu);
exit = engine->playGame(argv[0]);
}
else if (input == "2")
{
menu.printMessage("Enter the filename from which load a game");
std::string fileName = menu.getInput();
if (!std::cin.eof())
{
try
{
engine = saver.load(fileName, &menu);
if (engine != nullptr)
{
menu.printMessage("Azul game successfully loaded");
exit = engine->playGame();
}
}
catch (const char* errorMessage)
{
std::string message(errorMessage);
menu.printMessage("Error reading file - "+message+"\n");
}
}
else exit = true;
}
else if (input == "3")
{
menu.printCredits();
}
else if (std::cin.eof() || input == "4")
{
exit = true;
}
else
{
menu.printMessage("Invalid input, try again");
}
} while (!exit);
menu.printMessage("Goodbye");
if (engine != nullptr) delete engine;
return 0;
}