Skip to content

Commit 153d9f1

Browse files
committed
Add conf file
1 parent 0c32adb commit 153d9f1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
#include <SFML/Graphics.hpp>
22
#include <vector>
33
#include <list>
4+
#include <fstream>
45
#include "colony.hpp"
56
#include "config.hpp"
67
#include "display_manager.hpp"
78

89

10+
uint32_t loadUserConf()
11+
{
12+
uint32_t ants_count = 512;
13+
std::ifstream conf_file("conf.txt");
14+
if (conf_file) {
15+
conf_file >> ants_count;
16+
}
17+
else {
18+
std::cout << "Couldn't find 'conf.txt', loading default" << std::endl;
19+
}
20+
21+
return ants_count;
22+
}
23+
24+
925
int main()
1026
{
1127
sf::ContextSettings settings;
@@ -14,9 +30,10 @@ int main()
1430
window.setFramerateLimit(60);
1531

1632
Conf::loadTextures();
33+
const uint32_t ants_count = loadUserConf();
1734

1835
World world(Conf::WIN_WIDTH, Conf::WIN_HEIGHT);
19-
Colony colony(Conf::WIN_WIDTH/2, Conf::WIN_HEIGHT/2, 512);
36+
Colony colony(Conf::WIN_WIDTH/2, Conf::WIN_HEIGHT/2, ants_count);
2037
world.addMarker(Marker(colony.position, Marker::ToHome, 10.0f, true));
2138

2239
DisplayManager display_manager(window, window, world, colony);

0 commit comments

Comments
 (0)