-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (43 loc) · 1.17 KB
/
Copy pathmain.cpp
File metadata and controls
59 lines (43 loc) · 1.17 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Particle collisions physics using SFML
*
*
* Created by Patrick Fox, 25th July 2019
* http://pnfox.com
*/
#include <iostream>
#include "particles.h"
using namespace std;
int main(int argc, char *argv[]) {
const sf::VideoMode screenSize = sf::VideoMode(800, 600, 24);
sf::RenderWindow window(screenSize, "SFML Particles");
window.setFramerateLimit(60);
window.setActive(false);
window.requestFocus();
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
sf::Time timePerFrame = sf::seconds(1.f/60.f);
ParticlePool particles = ParticlePool();
// Main Loop here
while(window.isOpen())
{
sf::Time elapsedTime = clock.restart();
timeSinceLastUpdate += elapsedTime;
if(timeSinceLastUpdate < timePerFrame)
continue;
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
{
window.close();
break;
}
}
window.clear();
particles.Update(window);
window.display();
timeSinceLastUpdate = sf::Time::Zero;
}
return 0;
}