From dfe499248f1b1236487156b28e4a535d7963fe35 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Wed, 27 Aug 2008 15:48:50 +0000 Subject: major commit. game client restructure. not complete, loads of stuff not working, but the structure is there --- src/game/client/components/particles.hpp | 91 ++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/game/client/components/particles.hpp (limited to 'src/game/client/components/particles.hpp') diff --git a/src/game/client/components/particles.hpp b/src/game/client/components/particles.hpp new file mode 100644 index 00000000..6c466d94 --- /dev/null +++ b/src/game/client/components/particles.hpp @@ -0,0 +1,91 @@ +#include +#include + +// particles +struct PARTICLE +{ + void set_default() + { + vel = vec2(0,0); + life_span = 0; + start_size = 32; + end_size = 32; + rot = 0; + rotspeed = 0; + gravity = 0; + friction = 0; + flow_affected = 1.0f; + color = vec4(1,1,1,1); + } + + vec2 pos; + vec2 vel; + + int spr; + + float flow_affected; + + float life_span; + + float start_size; + float end_size; + + float rot; + float rotspeed; + + float gravity; + float friction; + + vec4 color; + + // set by the particle system + float life; + int prev_part; + int next_part; +}; + +class PARTICLES : public COMPONENT +{ + friend class GAMECLIENT; +public: + enum + { + GROUP_PROJECTILE_TRAIL=0, + GROUP_EXPLOSIONS, + GROUP_GENERAL, + NUM_GROUPS + }; + + PARTICLES(); + + void add(int group, PARTICLE *part); + + virtual void on_reset(); + virtual void on_render(); + +private: + + enum + { + MAX_PARTICLES=1024*8, + }; + + PARTICLE particles[MAX_PARTICLES]; + int first_free; + int first_part[NUM_GROUPS]; + + void render_group(int group); + void update(float time_passed); + + template + class RENDER_GROUP : public COMPONENT + { + public: + PARTICLES *parts; + virtual void on_render() { parts->render_group(TGROUP); } + }; + + RENDER_GROUP render_trail; + RENDER_GROUP render_explosions; + RENDER_GROUP render_general; +}; -- cgit 1.4.1