/
water_particle_system.hpp
72 lines (53 loc) · 1.48 KB
/
water_particle_system.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
#ifndef water_PARTICLE_SYSTEM_H
#define water_PARTICLE_SYSTEM_H
#include "graphics.hpp"
#include <deque>
#include "color_utils.hpp"
#include "foreach.hpp"
#include "geometry.hpp"
#include "entity.hpp"
#include "particle_system.hpp"
#include "variant.hpp"
struct water_particle_system_info {
water_particle_system_info(variant node);
int number_of_particles;
int repeat_period;
int velocity_x, velocity_y;
int velocity_rand;
int dot_size;
union {
uint8_t rgba[4];
uint32_t irgba;
};
};
class water_particle_system_factory : public particle_system_factory {
public:
explicit water_particle_system_factory(variant node);
~water_particle_system_factory() {}
particle_system_ptr create(const entity& e) const;
water_particle_system_info info;
};
class water_particle_system : public particle_system
{
public:
water_particle_system(const entity& e, const water_particle_system_factory& factory);
bool is_destroyed() const { return false; }
void process(const entity& e);
void draw(const rect& area, const entity& e) const;
private:
variant get_value(const std::string& key) const { return variant(); }
void set_value(const std::string& key, const variant& value);
const water_particle_system_factory& factory_;
const water_particle_system_info& info_;
int cycle_;
rect area_;
struct particle {
GLfloat pos[2];
GLfloat velocity;
};
GLfloat direction[2];
GLfloat base_velocity;
int velocity_x_, velocity_y_;
std::vector<particle> particles_;
};
#endif