This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
main.cpp
80 lines (72 loc) · 1.87 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
80
#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>
#include <sstream>
#include <string>
#include <utility>
#include <memory>
#include <SFML/Graphics.hpp>
#include <Thor/Resources.hpp>
#include <Box2D/Box2D.h>
#include <anax/anax.hpp>
#include <LuaContext.hpp>
#include <SFGUI/SFGUI.hpp>
#include "fsm.hpp"
#include "entities.hpp"
#include "listeners.hpp"
#include "managers.hpp"
#include "ai.hpp"
#include "Constants.hpp"
int main()
{
using std::vector;
using std::string;
using std::make_pair;
using std::chrono::milliseconds;
using sf::Event;
using sf::ContextSettings;
using sf::RenderWindow;
using sf::VideoMode;
using sf::View;
using namespace util;
using namespace ray;
GameManager gm;
Constants::loadConstants(*(gm.getLuaContext()));
RenderWindow& window = *gm.getRenderWindow();
// Create the main window
entities::setLuaState(gm.getLuaContext());
entities::initBaseTypes(gm);
entities::initManagerTypeBindings(gm);
entities::initComponentLuaBindings(gm);
ai::initAIBindings(gm);
vector<Event> events;
bool focused = true;
while (window.isOpen())
{
// Process events
Event event;
while (window.pollEvent(event))
{
events.push_back(event);
// Close window : exit
switch (event.type) {
case Event::Closed:
window.close();
break;
case Event::LostFocus:
focused = false;
break;
case Event::GainedFocus:
focused = true;
break;
case Event::KeyPressed:
break;
default:
; // nop
}
}
gm.getStateMachine()->update(events);
events.clear();
}
}