-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (33 loc) · 1.13 KB
/
main.cpp
File metadata and controls
45 lines (33 loc) · 1.13 KB
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
#include <SFML/Graphics.hpp>
#include <string>
#include "Config.hpp"
#include "World.hpp"
#include "Particle.hpp"
#include "VisualText.hpp"
int main() {
srand(1);
sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Particle Sim");
window.setFramerateLimit(60);
sf::Clock clock, spawner;
VisualText visualText;
InputState inpState;
// Particle count, substeps, savePos (1 = yes, 0 = no)
World world(56'000, 8, 0);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
window.close();
}
}
world.spawnIfPossible(spawner.restart().asSeconds(), spawner);
visualText.setParticle(std::to_string(world.particles.size()));
visualText.setFrames(std::to_string(clock.restart().asMilliseconds()));
window.clear(sf::Color::White);
inpState.update(window);
world.update(inpState);
world.draw(window);
visualText.draw(window);
window.display();
}
}