-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
79 lines (73 loc) · 2.9 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
77
78
79
#include <iostream>
#include <vector>
#include <string>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "toolbox.h"
#include "programaction.h"
#include "databattle.h"
#include "databattleeditor.h"
#include "titlescreen.h"
#include "hud.h"
#include "scene.h"
#include "npc.h"
int main()
{
sf::RenderWindow window(sf::VideoMode(1024, 576), "NETMAP 1.0");
window.setFramerateLimit(60);
HUD* testHUD = new HUD();
Player* PLAYER = new Player;
testHUD->setPlayer(PLAYER);
Netmap_Playable* CURRENT_PLAYABLE = new TitleScreen();
//Netmap_Playable* CURRENT_PLAYABLE = new Scene("RNA_1"); // Testing out scenes
//Netmap_Playable* CURRENT_PLAYABLE = new NPC("RNA_Gemma_1");
string nextPlayable;
string lastPlayable = "quit:"; //"scene:testScene";
//Netmap_Playable* CURRENT_PLAYABLE = new DataBattle("TestBattle");
while (true) {
CURRENT_PLAYABLE->setHUD(testHUD);
CURRENT_PLAYABLE->setPlayer(PLAYER);
nextPlayable = CURRENT_PLAYABLE->play(&window);
delete CURRENT_PLAYABLE;
cout << "Deletion of CURRENT_PLAYABLE successful\n";
if (startsWith(nextPlayable, "quit:") || (nextPlayable.size() == 0)) {
cout << "Quitting game\n";
break;
} else if (startsWith(nextPlayable, "editor:")) {
cout << "Launching editor\n";
CURRENT_PLAYABLE = new DataBattleEditor(splitString(nextPlayable, ':')[1]);
} else if (startsWith(nextPlayable, "db:")) {
cout << "Launching DB\n";
CURRENT_PLAYABLE = new DataBattle(splitString(nextPlayable, ':')[1]);
} else if (startsWith(nextPlayable, "dbFromEditor:")) {
cout << "Launching DB from editor\n";
CURRENT_PLAYABLE = new DataBattle(splitString(nextPlayable, ':')[1]);
CURRENT_PLAYABLE->destination = "editor:" + splitString(nextPlayable, ':')[1];
cout << "Creation successful\n";
} else if (startsWith(nextPlayable, "title:")) {
cout << "Returning to title\n";
CURRENT_PLAYABLE = new TitleScreen();
} else if (startsWith(nextPlayable, "scene:")) {
cout << "Launching scene\n";
CURRENT_PLAYABLE = new Scene(splitString(nextPlayable, ':')[1]);
} else if (startsWith(nextPlayable, "npc:")) {
cout << "Launching NPC\n";
vector<string> splitPlayable = splitString(nextPlayable, ':');
CURRENT_PLAYABLE = new NPC(splitPlayable[1]);
CURRENT_PLAYABLE->destination = lastPlayable;
}
lastPlayable = nextPlayable;
}
cout << "Loop exited\n";
// We need to clean things up before we exit the program
delete PLAYER;
delete testHUD;
for (pair<string, Program*> p : PROGRAM_DB) {
delete p.second;
}
for (pair<string, ProgramAction*> p : ACTION_DB) {
delete p.second;
}
cout << "Cleanup complete\n";
return 0;
}