textpsys

view src/psys.h @ 3:b1c8d2784c72

made the timer internal to the effect, fx_draw doesn't take a time value any more
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 20 Aug 2015 06:40:23 +0300
parents a4ffd9e6984c
children
line source
1 #ifndef PSYS_H_
2 #define PSYS_H_
4 #include <vector>
5 #include "vec3.h"
6 #include "image.h"
8 struct PSysParam {
9 // emitter parameters
10 float spawn_rate;
11 float spawn_range;
12 float life, life_range;
13 float size, size_range;
14 Vector3 gravity;
15 Image *spawn_map;
16 float spawn_map_speed;
18 // particle parameters
19 Image *pimg;
20 Vector3 pcolor_start, pcolor_mid, pcolor_end;
21 float palpha_start, palpha_mid, palpha_end;
22 float pscale_start, pscale_mid, pscale_end;
23 };
25 void psys_default(PSysParam *pp);
27 struct Particle {
28 Vector3 pos, vel;
29 Vector3 color;
30 float alpha;
31 float life, max_life;
32 float size, scale;
34 struct Particle *next;
35 };
37 class ParticleSystem {
38 private:
39 float spawn_pending;
40 Particle *plist;
41 int pcount;
43 float active_time;
44 bool expl;
45 Vector3 expl_cent;
46 float expl_force, expl_dur;
47 float expl_life;
49 Vector3 *smcache;
50 int smcache_max[256];
51 void gen_spawnmap(int count);
53 void spawn_particle();
55 public:
56 Vector3 pos;
57 PSysParam pp;
58 bool active;
60 ParticleSystem();
61 ~ParticleSystem();
63 void reset();
65 void explode(const Vector3 &c, float force, float dur = 1.0, float life = 0.0);
67 bool alive() const;
69 void update(float dt);
70 void draw() const;
71 };
73 #endif // PSYS_H_