Skip to content

Commit

Permalink
Add comments in main
Browse files Browse the repository at this point in the history
  • Loading branch information
johnBuffer committed Aug 9, 2021
1 parent 3402b6f commit 430da9b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/render/colony_renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct ColonyRenderer

const float margin = 10.0f;
const sf::Vector2f size(400.0f, 100.0f);
const float colonies_count = 4.0f;
const float colonies_count = 2.0f;
const float start_x = (Conf::WIN_WIDTH - size.x * colonies_count - (colonies_count - 1.0f) * margin) * 0.5f;
population.configure({start_x + (size.x + margin) * colony.id, margin}, size);
population.population.color = colony.ants_color;
Expand Down
2 changes: 1 addition & 1 deletion include/simulation/colony/colony.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct Colony
, id(col_id)
{
base.food = 0.0f;
uint32_t ants_count = 2000;
uint32_t ants_count = 16;
for (uint32_t i(ants_count); i--;) {
createWorker();
}
Expand Down
15 changes: 7 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ int main()
simulation.createColony(margin, margin);
simulation.createColony(Conf::WORLD_WIDTH - margin, Conf::WORLD_HEIGHT - margin);
simulation.loadMap("res/map.png");
simulation.renderer.vp_handler.reset();

sf::Clock clock;
RMean<float> fps(100);
Expand All @@ -31,24 +32,22 @@ int main()
fps_text.setCharacterSize(32);
fps_text.setFillColor(sf::Color::White);
fps_text.setPosition(10.0f, 10.0f);
const float dt = 0.016f;

while (window.isOpen())
{
while (window.isOpen()) {
// Update simulation
simulation.processEvents();

const float dt = 0.016f;
simulation.update(dt);

// Update FPS metric
fps_text.setString(toStr(fps.get()));

// Render simulation
window.clear(sf::Color(94, 87, 87));
simulation.render(window);
window.draw(fps_text);
window.display();

// Add render time to the counter
fps.addValue(1.0f / clock.restart().asSeconds());
}

// Free textures
Conf::freeTextures();

Expand Down

0 comments on commit 430da9b

Please sign in to comment.