📄 ch18p2_particle.h
字号:
class CParticle
{
public:
CParticle() { m_fWeight = 1.0f; m_fSize = 1.0f; m_fLifetime = 1.0f; m_fAge = 0.0f; }
virtual ~CParticle() { }
float m_fWeight;
float m_fSize;
float m_fLifetime;
float m_fAge;
D3DXCOLOR m_Color;
D3DXCOLOR m_ColorStep;
D3DXVECTOR3 m_vPos; // current position of particle
D3DXVECTOR3 m_vDir;
// this function is inline not because it's small, but because it's only called
// in one place (CParticleEmitter.Update()). This way we can also dodge the
// performance hit associated with calling a function many times (remember, we're
// in a for loop in CParticleEmitter.Update()).
// your needs may vary. For example, if you can afford the speed hit, it might
// be cool to make this a virtual function.
inline bool Update(float fTimeDelta)
{
// age the particle
m_fAge += fTimeDelta;
// if this particle's age is greater than it's lifetime, it dies.
if (m_fAge >= m_fLifetime) {
return(false); // dead!
}
// move particle
m_vPos += m_vDir * fTimeDelta;
m_Color += m_ColorStep * fTimeDelta;
return(true); // particle stays alive
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -