-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathParticleManager.hpp
80 lines (56 loc) · 1.38 KB
/
ParticleManager.hpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include "SDL.h"
#include <vector>
#include "Spritesheet.hpp"
#include <vector>
#include <algorithm>
// No direct support for Filled polygons
//namespace ShapeParticle {
// struct ShapeParticle {
// float x, y, x_vel, y_vel;
// float x_grav, y_grav;
//
// uint8_t sides;
// float angle;
//
// //COLOUR colour;
// bool filled;
// };
//}
class ImageParticle {
public:
ImageParticle();
ImageParticle(uint16_t sprite_index, float x, float y, float x_vel = 0.0f, float y_vel = 0.0f, float x_grav = 0.0f, float y_grav = 0.0f, float angle = 0.0f, float spin = 0.0f, float scale = 1.0f, float alpha = 255.0f, float fade = 0.0f);
void update(float dt);
void render(Spritesheet& spritesheet);
float get_x();
float get_y();
float get_scale();
float get_alpha();
private:
uint16_t sprite_index = 0;
float x = 0.0f;
float y = 0.0f;
float x_vel = 0.0f;
float y_vel = 0.0f;
float x_grav = 0.0f;
float y_grav = 0.0f;
float angle = 0.0f;
float spin = 0.0f;
float scale = 1.0f;
float alpha = 255.0f;
float fade = 0.0f;
};
class ParticleHandler {
public:
ParticleHandler();
void update(float dt);
void render(Spritesheet& spritesheet);
//void add(ShapeParticle::ShapeParticle);
void add(ImageParticle particle);
void remove_if(bool (*condition) (ImageParticle&));
void clear();
uint16_t count_particles();
private:
std::vector<ImageParticle> image_particles;
};