-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (46 loc) · 1.4 KB
/
main.cpp
File metadata and controls
50 lines (46 loc) · 1.4 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
#include <iostream>
#include <stdlib.h>
#include "menu.h"
#include "options.h"
#include "game.h"
#include "states.h"
using namespace std;
int main(int argc, char **argv) {
// game state elements
Menu menu = Menu();
Options options = Options();
Game game = Game();
int state = menuState;
// start the main loop
do {
// check the current state of the game
switch (state) {
case menuState:
// Enter the menu state dialog
state = menu.show();
break;
case gameState:
// Start the main game part
state = game.show();
break;
case optionsState:
// Enter the options dialog
state = options.show();
break;
case unknownState:
// An unknown state, return to the main menu state
cout << "please select one of the menu entries" << endl;
state = menuState;
break;
default:
// something else happened return to the main menu
state = menuState;
break;
}
//check if we got to the exit state
} while (state != exitState);
// output a note for the user that the game will be quit
cout << "exit game" << endl;
// quit with success
return EXIT_SUCCESS;
}