DDraceNetwork Docs
particles.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_PARTICLES_H
4#define GAME_CLIENT_COMPONENTS_PARTICLES_H
5#include <base/color.h>
6#include <base/vmath.h>
8
9// particles
11{
13 {
14 m_Pos = vec2(0, 0);
15 m_Vel = vec2(0, 0);
16 m_LifeSpan = 0;
17 m_StartSize = 32;
18 m_EndSize = 32;
19 m_UseAlphaFading = false;
20 m_StartAlpha = 1;
21 m_EndAlpha = 1;
22 m_Rot = 0;
23 m_Rotspeed = 0;
24 m_Gravity = 0;
25 m_Friction = 0;
26 m_FlowAffected = 1.0f;
27 m_Color = ColorRGBA(1, 1, 1, 1);
28 m_Collides = true;
29 }
30
33
34 int m_Spr;
35
37
39
41 float m_EndSize;
42
46
47 float m_Rot;
49
50 float m_Gravity;
52
54
56
57 // set by the particle system
58 float m_Life;
61};
62
63class CParticles : public CComponent
64{
65 friend class CGameClient;
66
67public:
68 enum
69 {
76 };
77
78 CParticles();
79 virtual int Sizeof() const override { return sizeof(*this); }
80
81 void Add(int Group, CParticle *pPart, float TimePassed = 0.f);
82
83 virtual void OnReset() override;
84 virtual void OnRender() override;
85 virtual void OnInit() override;
86
87private:
90
91 enum
92 {
93 MAX_PARTICLES = 1024 * 8,
94 };
95
99
100 float m_FrictionFraction = 0.0f;
101 int64_t m_LastRenderTime = 0;
102
103 void RenderGroup(int Group);
104 void Update(float TimePassed);
105
106 template<int TGROUP>
108 {
109 public:
111 virtual int Sizeof() const override { return sizeof(*this); }
112 virtual void OnRender() override { m_pParts->RenderGroup(TGROUP); }
113 };
114
115 // behind players
118 // in front of players
122
123 bool ParticleIsVisibleOnScreen(const vec2 &CurPos, float CurSize);
124};
125#endif
Definition: component.h:20
Definition: gameclient.h:124
Definition: particles.h:108
virtual int Sizeof() const override
Definition: particles.h:111
virtual void OnRender() override
Definition: particles.h:112
CParticles * m_pParts
Definition: particles.h:110
Definition: particles.h:64
CRenderGroup< GROUP_EXTRA > m_RenderExtra
Definition: particles.h:120
CRenderGroup< GROUP_PROJECTILE_TRAIL > m_RenderTrail
Definition: particles.h:116
virtual void OnInit() override
Definition: particles.cpp:169
CParticles()
Definition: particles.cpp:13
virtual int Sizeof() const override
Definition: particles.h:79
int64_t m_LastRenderTime
Definition: particles.h:101
virtual void OnReset() override
Definition: particles.cpp:23
void Update(float TimePassed)
Definition: particles.cpp:77
@ GROUP_PROJECTILE_TRAIL
Definition: particles.h:70
@ GROUP_EXTRA
Definition: particles.h:73
@ NUM_GROUPS
Definition: particles.h:75
@ GROUP_TRAIL_EXTRA
Definition: particles.h:71
@ GROUP_GENERAL
Definition: particles.h:74
@ GROUP_EXPLOSIONS
Definition: particles.h:72
float m_FrictionFraction
Definition: particles.h:100
CRenderGroup< GROUP_EXPLOSIONS > m_RenderExplosions
Definition: particles.h:119
int m_aFirstPart[NUM_GROUPS]
Definition: particles.h:98
int m_FirstFree
Definition: particles.h:97
void RenderGroup(int Group)
Definition: particles.cpp:209
@ MAX_PARTICLES
Definition: particles.h:93
CRenderGroup< GROUP_TRAIL_EXTRA > m_RenderTrailExtra
Definition: particles.h:117
int m_ExtraParticleQuadContainerIndex
Definition: particles.h:89
CParticle m_aParticles[MAX_PARTICLES]
Definition: particles.h:96
void Add(int Group, CParticle *pPart, float TimePassed=0.f)
Definition: particles.cpp:40
int m_ParticleQuadContainerIndex
Definition: particles.h:88
bool ParticleIsVisibleOnScreen(const vec2 &CurPos, float CurSize)
Definition: particles.cpp:194
virtual void OnRender() override
Definition: particles.cpp:146
CRenderGroup< GROUP_GENERAL > m_RenderGeneral
Definition: particles.h:121
Definition: color.h:210
Definition: particles.h:11
int m_PrevPart
Definition: particles.h:59
float m_Gravity
Definition: particles.h:50
int m_Spr
Definition: particles.h:34
float m_Rotspeed
Definition: particles.h:48
float m_LifeSpan
Definition: particles.h:38
int m_NextPart
Definition: particles.h:60
float m_EndSize
Definition: particles.h:41
ColorRGBA m_Color
Definition: particles.h:53
float m_FlowAffected
Definition: particles.h:36
void SetDefault()
Definition: particles.h:12
float m_Rot
Definition: particles.h:47
float m_EndAlpha
Definition: particles.h:45
bool m_UseAlphaFading
Definition: particles.h:43
float m_Friction
Definition: particles.h:51
float m_StartSize
Definition: particles.h:40
float m_Life
Definition: particles.h:58
vec2 m_Pos
Definition: particles.h:31
vec2 m_Vel
Definition: particles.h:32
bool m_Collides
Definition: particles.h:55
float m_StartAlpha
Definition: particles.h:44
vector2_base< float > vec2
Definition: vmath.h:158