-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (36 loc) · 1.11 KB
/
main.cpp
File metadata and controls
51 lines (36 loc) · 1.11 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
#include <SFML\Graphics\RenderWindow.hpp>
#include <SFML\Window\Event.hpp>
#include "particlesystem.hpp"
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "phell");
Background bg;
ParticleSystem ps(bg);
sf::Clock clock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Space)
ps.toggle();
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Num1)
ps.setCurrentParticle(Particle::ICE);
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Num2)
ps.setCurrentParticle(Particle::LAVA);
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Num3)
ps.setCurrentParticle(Particle::IONIC);
}
sf::Time elapsed = clock.restart();
ps.moveEmitter(elapsed);
ps.setLookAt(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
ps.update(elapsed);
window.clear();
bg.draw(&window);
window.draw(ps);
window.display();
}
return 0;
}