-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
76 lines (62 loc) · 2.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "config.h"
#include "startdialog.h"
#include "stage2gamefactory.h"
#include "stage2gamestatefactory.h"
#include "tester.h"
#include "stage3gamefactory.h"
#include "stage3gamestatefactory.h"
#include "scoreboarddialog.h"
#include "teststage3.h"
#include <QApplication>
#include <QSound>
#include <iostream>
#include <memory>
// these 2 are flag for using stage 3
static bool stage3 = true;
static bool test3 = false;
//Allocating and initializing Config static data member. The pointer is being allocated - not the object itself
int main(int argc, char* argv[]) {
QApplication a(argc, argv);
//Sets up the config class for all files to use
Config::config()->setupConfig();
//Infinite loop of background music
QSound sound(":sound/background_music.wav");
sound.setLoops(-1);
sound.play();
// if stage 3 flag enable
if (stage3) {
// Create testing interface with a separate game state.
auto state_factory = std::unique_ptr<GameStateFactory>(new Stage3GameStateFactory());
Tester tester(state_factory);
tester.run(2048);
// if stage 3 test is enabled, run it
if (test3) {
TestStage3 test(state_factory);
test.run();
} else {
// Create rendered version of the game
GameFactory* factory = new Stage3GameFactory();
StartDialog start_dialog(factory);
start_dialog.setWindowTitle("Main Menu");
start_dialog.show();
// create scoreboard
ScoreboardDialog::scoreboard();
ScoreboardDialog::scoreboard()->setModal(true);
ScoreboardDialog::scoreboard()->setWindowTitle("Scoreboard");
auto exit_code = a.exec();
return exit_code;
}
} else {
// Create testing interface with a separate game state.
auto state_factory = std::unique_ptr<GameStateFactory>(new Stage2GameStateFactory());
Tester tester(state_factory);
tester.run(2048);
// Create rendered version of the game
GameFactory* factory = new Stage2GameFactory();
StartDialog start_dialog(factory);
start_dialog.setWindowTitle("Main Menu");
start_dialog.show();
auto exit_code = a.exec();
return exit_code;
}
}