www.pudn.com > sxdl.zip > cBomb.cpp
#include "cBomb.h"
#include "cBoomBastic.h"
#include "bbUtil.h"
#include "cTank.h"
#define BOMB_SIZE 48.0f
cBomb::cBomb(int BombX, int BombY, int Power, int OwnerID) :
cExplosiveDevice(Power)
{
m_BombX = BombX;
m_BombY = BombY;
m_OwnerID = OwnerID;
//Le tank qui a pose une bombe en a une de moins
if (g_BoomBastic.IsStillAlive[m_OwnerID])
g_BoomBastic.Tanks[OwnerID]->NbBombs--;
//La bombe explose au bout de 2 secondes
LifeTime = 2.0f;
Family = BOMB_ID;
Position = g_BoomBastic.Tilemap->MapToWorld(m_BombX, m_BombY);
g_BoomBastic.Tilemap->LogicalMap(m_BombX, m_BombY, LMAP_BOMB);
WillRenderLike(g_BoomBastic.EntitySprites[BOMB_SPRITE]);
Activate();
}
bool cBomb::OnAnimate(float ElapsedTime, float AbsoluteTime)
{
cExplosiveDevice::OnAnimate(ElapsedTime, AbsoluteTime);
//On calcule la nouvelle taille de la bombe (la taille de la bombe evolue au cours du temps)
float Size = BOMB_SIZE * (fabsf(sinf(Age * Pi / 2.0f)) * 0.25f + 0.75f);
Scale = Vector3(Size, Size, 1.0f);
return true;
}
void cBomb::OnDying()
{
cExplosiveDevice::OnDying();
//Le tank qui a pose une bombe peut en poser une de plus
if (g_BoomBastic.IsStillAlive[m_OwnerID])
g_BoomBastic.Tanks[m_OwnerID]->NbBombs++;
}