home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
structures.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-10-08
|
3KB
|
151 lines
#include "main.h"
//incializacia
//-----------------------------------------------------------
void STRUCTURE::Initialize()
{
Reset();
}
//reset
//-----------------------------------------------------------
void STRUCTURE::Reset()
{
Pos = Get3D(0.0f,0.0f,0.0f);
Rot = Get3D(0.0f,0.0f,0.0f);
ModelIndex = 0;
//aktivacia
Active = false;
ActiveTime = 0.0f;
Life = 1;
//mody
Normal = true;
Destroyed = false;
}
//render a obnovenie
//-----------------------------------------------------------
void STRUCTURE::Refresh()
{
if (Active == false)
return;
//---------
//Process
//---------
Matrix = GetMatrix(Pos,Rot,F_Scale);
if (Life <= 0)
{
if (Normal == true)
{
//particle
//pretransformuj vybusne body
for (int i=0;i<NumSmokePoints;i++)
{
TransformSmokePoint[i] = TransformPoint(SmokePoint[i],Matrix);
Explo.SpawnExplosion(TransformSmokePoint[i]);
Explo.SpawnParticle(TransformSmokePoint[i]);
Explo.F_Plane.Spawn(Get3D(TransformSmokePoint[i].X,
TransformSmokePoint[i].Y,
TransformSmokePoint[i].Z));
Explo.F_Ball.Spawn(TransformSmokePoint[i]);
}
//zvuk
SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
SoundLib.ExplodeLarge.Play();
if (Target == true)
{
//vypusti score particle
Score.DrawScore(Score_Structure,Pos);
//pripocita score
SpitFire.Score += Score_Structure;
}
}
Normal = false;
Destroyed = true;
}
//---------
//Render
//---------
//ak je strom zapni blending
if (ModelIndex >= Index_Structure_Strom1)
{
Engine.SetBlendTrans();
Engine.SetAlphaTest(true);
Engine.SetFilter(0,D3DTEXF_POINT);
}
if (Normal == true)
{
ModelLib.GetStructure(ModelIndex)->Pos = Pos;
ModelLib.GetStructure(ModelIndex)->Rot = Rot;
ModelLib.GetStructure(ModelIndex)->Render();
}
if (Destroyed == true)
{
ModelLib.GetDestroyedStructure(ModelIndex)->Pos = Pos;
ModelLib.GetDestroyedStructure(ModelIndex)->Rot = Rot;
ModelLib.GetDestroyedStructure(ModelIndex)->Render();
if (ActiveTime < Structure_DestroyTime)
{
ActiveTime += PowerTime(1.0f);
//pretransformuj vybusne body
for (int i=0;i<NumSmokePoints;i++)
{
TransformSmokePoint[i] = TransformPoint(SmokePoint[i],Matrix);
Explo.SpawnSmokeGround(TransformSmokePoint[i]);
}
}
}
//ak je strom vypni blending
if (ModelIndex >= Index_Structure_Strom1)
{
Engine.SetBlendNone();
Engine.SetAlphaTest(false);
Engine.SetFilter(0,D3DTEXF_LINEAR);
}
}
//kolizia box
//-----------------------------------------------------------
bool STRUCTURE::CollisionBox(VECTOR3D P1, VECTOR3D P2)
{
if (Active == false)
return false;
return ModelLib.GetStructure(ModelIndex)->CollisionBox(P1,P2,Matrix);
}
//kolizia detail
//-----------------------------------------------------------
bool STRUCTURE::CollisionDetail(VECTOR3D P1, VECTOR3D P2)
{
if (Active == false)
return false;
return ModelLib.GetStructure(ModelIndex)->CollisionDetail(P1,P2,Matrix);
}