/
sistragatiwe.cpp
56 lines (41 loc) · 1.37 KB
/
sistragatiwe.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
#include <iostream>
#include <SFML/Graphics.hpp>
#include "lib/include/world.hpp"
#include "lib/include/message.hpp"
#include "lib/include/message_spec.hpp"
sf::Mutex mutex;
int main() {
sf::RenderWindow window(sf::VideoMode(800, 600), "Sistragatiwe");
window.setFramerateLimit(30);
World world(window, "resources/maps/test/test.xml");
// not that eveything is initialized start the
// game logic loop
sf::Thread logic_thread(&World::gameLogic, &world);
logic_thread.launch();
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
} else if (event.type == sf::Event::Resized) {
sf::View view(window.getView());
view.setSize(event.size.width, event.size.height);
window.setView(view);
} else if (event.type == sf::Event::MouseButtonReleased) {
sf::Vector2i pos = sf::Mouse::getPosition(window);
sf::Vector2f v = window.mapPixelToCoords(pos);
}
mutex.lock();
world.events.push(event);
mutex.unlock();
}
mutex.lock();
window.clear(sf::Color(25, 130, 225));
window.draw(world.map);
window.draw(world.gui);
window.display();
mutex.unlock();
}
logic_thread.terminate();
return 0;
}