home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
truck.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-09-28
|
4KB
|
213 lines
#include "main.h"
//inicializacia
//--------------------------------------------------------------
void TRUCK::Initialize()
{
//Bullet
//---------
Bullet.Initialize();
Bullet.UnFriendly = true;
//reset
//-------
Reset();
}
//reset
//--------------------------------------------------------------
void TRUCK::Reset()
{
//vlastnosti
Life = 150;
//aktivacia
Active = false;
ActiveTime = 0.0f;
//ciel
Target = false;
//m≤dy
NormalMode = true;
DestroyedMode = false;
CrazyMode = false;
//AI mody
Utok = false;
Sledovanie = true;
//pozicia a matica
Pos = Get3D(0.0f,0.0f,0.0f);
Rot = Get3D(0.0f,0.0f,0.0f);
Matrix = GetMatrix(Pos,Rot,Get3D(1.0f,1.0f,1.0f));
//strely
Bullet.Reset();
BulletTime = 0.0f;
CannonPosition = Get3D(0.0f,0.0f,0.0f);
CannonRotation = Get3D(0.0f,0.0f,0.0f);
}
//refresh
//-------------------------------------------------------------
void TRUCK::Refresh()
{
//ak nieje aktviny vyhod
if (Active == false)
return;
//------------------------------------
//Vypocitanie matice a pomocnych bodov
//------------------------------------
Matrix = GetMatrix(Pos,Rot,F_Scale);
//-------------
//Process
//-------------
//vypocita vzdialonost
float Dis = CalcDistance(SpitFire.Pos,Pos);
if (Dis > Truck_Distance)
Utok = false;
else
Utok = true;
//
//Normal
//---------
if (NormalMode == true)
{
//-------
//pozicia
CannonPosition = TransformPoint(Truck_CannonPos,Matrix);
//rotacia
CannonRotation = GetRotationLok(CannonPosition,SpitFire.Pos);
//-------
if (Utok == true)
{
//strielanie
BulletTime += PowerTime(1.0f);
if (BulletTime > Truck_BulletFreq)
{
//vypusti bullet
Bullet.SpawnBullet(CannonPosition,CannonRotation);
//zvuk
SoundLib.FireUnFriendly.SetPosition(CannonPosition,FireUnFriendly_Scale);
SoundLib.FireUnFriendly.Play();
BulletTime = 0.0f;
}
}
//--------
if (Life <= 0)
{
CrazyMode = true;
NormalMode = false;
//particle
Explo.SpawnExplosion(Pos);
Explo.SpawnParticle(Pos);
Explo.F_Plane.Spawn(Get3D(Pos.X,Pos.Y,Pos.Z));
Explo.F_Ball.Spawn(Pos);
//zvuk
SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
SoundLib.ExplodeLarge.Play();
//vypusti score particle
Score.DrawScore(Score_Truck,Pos);
//pripocita score
SpitFire.Score += Score_Truck;
}
}
//
//CrazyMode
//---------
else if (CrazyMode == true)
{
ActiveTime += PowerTime(1.0f);
if (ActiveTime > Truck_CrazyTime)
{
DestroyedMode = true;
CrazyMode = false;
}
Pos.Y += Power(3.0f) * cosf(ActiveTime/500.0f);
}
//
//destroyed
//----------
else if (DestroyedMode == true)
{
//smoke
Explo.SpawnSmokeGround(Pos);
ActiveTime += PowerTime(1.0f);
if (ActiveTime > Truck_DestroyTime)
{
Active = false;
}
}
//--------------
//render
//--------------
//bullets
Bullet.Refresh();
//normal
if (NormalMode == true)
{
//podvozok
ModelLib.Truck_ModelBack.Pos = Pos;
ModelLib.Truck_ModelBack.Rot = Rot;
ModelLib.Truck_ModelBack.Render();
//cannon
ModelLib.Truck_ModelCannon.Pos = CannonPosition;
ModelLib.Truck_ModelCannon.Rot = CannonRotation;
ModelLib.Truck_ModelCannon.Render();
}
//CrazyMode Destroyed Mode
else if (CrazyMode == true || DestroyedMode == true)
{
ModelLib.Truck_ModelDestroyed.Pos = Pos;
ModelLib.Truck_ModelDestroyed.Rot = Rot;
ModelLib.Truck_ModelDestroyed.Render();
}
}
//kolizia box
//------------------------------------------------------------
bool TRUCK::CollisionBox(VECTOR3D P1, VECTOR3D P2)
{
return ModelLib.Truck_ModelDestroyed.CollisionBox(P1,P2,Matrix);
}
//kolizia detail
//-------------------------------------------------------------
bool TRUCK::CollisionDetail(VECTOR3D P1, VECTOR3D P2)
{
return ModelLib.Truck_ModelDestroyed.CollisionDetail(P1,P2, Matrix);
}