00001
00002
00009
00010
#include "ctrl_particule.h"
00011
#include "fx_explosion.h"
00012
00013 CExplosion::CExplosion (
CTexture *pTexture)
00014 {
00015
m_pTexture = pTexture;
00016 }
00017
00018 CExplosion::~CExplosion ()
00019 {
00020
00021 }
00022
00023 const CExplosion*
CExplosion::Create (
CEntite *pProprietaire,
float fTailleParticule,
const CVecteur & Position,
unsigned int uiForce,
float fDureeVie,
CCouleur Couleur)
00024 {
00025
00026
CExplosion* pGenerateurParticule =
CParticleManager::Instance ()->
CreateExplosion ();
00027
if (pGenerateurParticule == 0)
00028
return 0;
00029
00030 pGenerateurParticule->
m_fTailleParticule = fTailleParticule;
00031 pGenerateurParticule->
m_Position = Position;
00032 pGenerateurParticule->
m_fDureeVie = fDureeVie;
00033 pGenerateurParticule->
m_uiForce = uiForce;
00034 pGenerateurParticule->
m_Couleur = Couleur;
00035 pGenerateurParticule->
Init ();
00036
00037
return pGenerateurParticule;
00038 }
00039
00040
00041 void CExplosion::Init ()
00042 {
00043 m_DureeVie.
Init ();
00044
for (
unsigned int i = 0; i < m_uiForce; i++)
00045 {
00046
float fRandAngle =
RandFloat (-
M_PI,
M_PI);
00047
float fRandCos = cos (fRandAngle);
00048
float fRandSin = sin (fRandAngle);
00049
float fRandForce =
RandFloat (0.0f, (
float)m_uiForce);
00050
CVecteur Vitesse =
CVecteur (fRandCos * fRandForce, fRandSin * fRandForce);
00051
00052
int iIndex =
GetIndexLibre ();
00053
if (iIndex != -1)
00054 m_pParticule[iIndex] =
new CParticule (m_Position, Vitesse, -Vitesse / 6, m_fDureeVie, 1.0f);
00055 }
00056 }
00057
00058
00059 void CExplosion::Update ()
00060 {
00061
if (m_DureeVie.
GetTime () > m_fDureeVie)
00062 m_bSupprime =
true;
00063 }
00064