-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticals.h
54 lines (50 loc) · 1.77 KB
/
Particals.h
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
#pragma once
#include <SFML/Graphics.hpp>
#include <cmath>
#include <iostream>
#include <random>
class ParticleSystem : public sf::Drawable, public sf::Transformable {
public:
ParticleSystem(unsigned int count, unsigned int windowWidth,
unsigned int windowHeight, sf::PrimitiveType type);
ParticleSystem(unsigned int count, unsigned int windowWidth,
unsigned int windowHeight, sf::PrimitiveType type, sf::Color color, float speed, float rand_speed);
void setEmitter(sf::Vector2f position);
void draw(sf::RenderTarget &target, sf::RenderStates states) const override;
void setMovingDirectionEffect(const sf::Vector2f ¢er);
void update(sf::Time elapsed);
void spawnParticles(unsigned int count);
void resetParticle(std::size_t index);
void changeColor(sf::Color color, sf::Color color2);
void setParticlesType(sf::PrimitiveType type);
void setSpeed(int base_speed, float rand_speed);
struct Particle {
sf::Vector2f velocity;
sf::Time lifetime;
};
std::vector<Particle> m_particles;
sf::VertexArray m_vertices;
sf::Time m_lifetime;
sf::Vector2f m_emitter;
unsigned int count;
unsigned int m_windowWidth;
unsigned int m_windowHeight;
sf::PrimitiveType m_type;
float base_speed = 100;
float rand_speed = 100;
};
class Effects {
public:
Effects(sf::RenderTarget &target, sf::Clock &clock, unsigned int count,
const std::vector<std::vector<char>> &numbers);
void apply(const std::vector<std::vector<char>> &numbers);
bool on = false;
void apply(const int effect_type, const std::vector<std::vector<char>> &numbers);
void next();
private:
int current_effect = 0;
sf::RenderTarget ⌖
sf::Clock &clock;
unsigned int count;
const std::vector<std::vector<char>> &numbers;
};