home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
bombs.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-06-26
|
4KB
|
170 lines
#include "main.h"
//inicializacia
//-------------------------------------------------------------
void BOMBSYSTEM::Initialize()
{
Model.Normals = false;
Model.SmoothShading = false;
Model.Specular = true;
Model.FrustrumTest = false;
Model.InitializeAse(1,"models/spitfire/bomb.ase");
Model.LoadAse(0,"models/spitfire/bomb.ase");
Model.LoadTexture("models/spitfire/bomb.bmp",GetColor(1,0,1));
Model.SetMaterial(GetMaterial(GetColor(0.7f,0.7f,0.7f),
GetColor(1.0f,1.0f,1.0f),
GetColor(0.5f,0.5f,0.5f),
GetColor(0.2f,0.2f,0.2f),4.5f));
Friendly = false;
UnFriendly = false;
Reset();
}
//reset
//-------------------------------------------------------------
void BOMBSYSTEM::Reset()
{
for (int i=0;i<Bomb_MaxBombs;i++)
{
Bomb[i].Active = false;
}
}
//refresh
//-------------------------------------------------------------
void BOMBSYSTEM::Refresh()
{
for (int i=0;i<Bomb_MaxBombs;i++)
{
if (Bomb[i].Active == false)
continue;
//process
//--------
//ak spadne bod
if (Bomb[i].Pos.Y < -1000.0f)
Bomb[i].Active = false;
//kolizia
if (Collision(Bomb[i].Pos,Get3D(Bomb[i].Pos.X + Power(Bomb[i].BPower) * Bomb[i].Sme.X,
Bomb[i].Pos.Y + Power(Bomb[i].BPower) * Bomb[i].Sme.Y,
Bomb[i].Pos.Z + Power(Bomb[i].BPower) * Bomb[i].Sme.Z)))
{
//spusti particle
Explo.SpawnExplosion(Bomb[i].Pos);
Explo.SpawnParticle(Bomb[i].Pos);
Explo.F_Plane.Spawn(Bomb[i].Pos);
Explo.F_Ball.Spawn(Bomb[i].Pos);
//zvuk
SoundLib.ExplodeLarge.SetPosition(Bomb[i].Pos,ExplodeLarge_Scale);
SoundLib.ExplodeLarge.Play();
//deaktivuk
Bomb[i].Active = false;
continue;
}
//urcenie vektoru
Bomb[i].Sme.Y += Power(-0.03f);
//posunutie
Bomb[i].Pos.X += Power(Bomb[i].BPower) * Bomb[i].Sme.X;
Bomb[i].Pos.Y += Power(Bomb[i].BPower) * Bomb[i].Sme.Y;
Bomb[i].Pos.Z += Power(Bomb[i].BPower) * Bomb[i].Sme.Z;
//render
//---------
Model.Pos = Bomb[i].Pos;
Model.Rot = GetRotationSme(Bomb[i].Sme);
Model.Render();
//dym za bombou
Explo.SpawnSmokeBomb(Bomb[i].Pos);
}
}
//kollizia
//--------------------------------------------------------------
bool BOMBSYSTEM::Collision(VECTOR3D P1, VECTOR3D P2)
{
int i;
//
//Zem
if (Level.Krajina.Collise(P1,P2) == false)
{
return false;
}
VECTOR3D Point = Level.Krajina.IntPos;
VECTOR3D B1,B2,B3,B4;
B1 = Point; B1.X = Point.X - Bomb_Range; B1.Y = Point.Y + Bomb_Range;
B2 = Point; B2.X = Point.X + Bomb_Range; B2.Y = Point.Y - Bomb_Range;
B3 = Point; B3.Z = Point.Z - Bomb_Range; B3.Y = Point.Y + Bomb_Range;
B4 = Point; B4.Z = Point.Z + Bomb_Range; B4.Y = Point.Y - Bomb_Range;
//
//Strucure
for (i=0;i<Max_Structures;i++)
{
if (Level.Structure[i].CollisionBox(B1,B2) == true ||
Level.Structure[i].CollisionBox(B3,B4) == true)
{
Level.Structure[i].Life -= Bomb_Power;
}
}
//
//Truck
for (i=0;i<Max_Trucks;i++)
{
if (Level.Truck[i].CollisionBox(B1,B2) == true ||
Level.Truck[i].CollisionBox(B3,B4) == true)
{
Level.Truck[i].Life -= Bomb_Power;
}
}
return true;
}
//vypustenie bomby
//---------------------------------------------------------------
void BOMBSYSTEM::SpawnBomb(VECTOR3D Pos, VECTOR3D Rot, float BPower)
{
for (int i=0;i<Bomb_MaxBombs;i++)
{
if (Bomb[i].Active == true)
continue;
Bomb[i].Active = true;
Bomb[i].Pos = Pos;
Bomb[i].BPower = BPower;
Bomb[i].Sme.X = (cosf(Rot.X)*1.0f)*sinf(Rot.Y);
Bomb[i].Sme.Y = -1.0f * sinf(Rot.X);
Bomb[i].Sme.Z = (cosf(Rot.X)*1.0f)*cosf(Rot.Y);
break;
}
}