home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
spitfire.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-11-27
|
25KB
|
1,034 lines
#include "main.h"
//-------------
//Global
//-------------
SPITFIRE SpitFire;
//Inicializacia
//----------------------------------------------------------
void SPITFIRE::Initialize()
{
//normal model
//------------
ModelNormal1.Specular = true;
ModelNormal1.Normals = false;
ModelNormal1.SmoothShading = false;
ModelNormal1.SmoothShading = false;
ModelNormal1.MultiTexture = true;
//ModelNormal1.InitializeAse(1,"models/messerschmitt/messerschmitt.ase");
//ModelNormal1.LoadAse(0,"models/messerschmitt/messerschmitt.ase");
//ModelNormal1.LoadTexture("models/messerschmitt/messernormal.bmp",GetColor(1.0f,0.0f,1.0f));
ModelNormal1.InitializeAse(1,"models/spitfire/spitfire.ase");
ModelNormal1.LoadAse(0,"models/spitfire/spitfire.ase");
ModelNormal1.LoadTexture("models/spitfire/spitfirenormal1.bmp",GetColor(0.0f,1.0f,0.0f));
ModelNormal1.LoadEnviroMap("models/spitfire/enviro.bmp");
ModelNormal1.Sca = F_Scale;
ModelNormal1.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));
ModelNormal2.Specular = true;
ModelNormal2.Normals = false;
ModelNormal2.SmoothShading = false;
ModelNormal2.SmoothShading = false;
ModelNormal2.MultiTexture = true;
ModelNormal2.InitializeAse(1,"models/spitfire/spitfire.ase");
ModelNormal2.LoadAse(0,"models/spitfire/spitfire.ase");
ModelNormal2.LoadTexture("models/spitfire/spitfirenormal2.bmp",GetColor(0.0f,1.0f,0.0f));
ModelNormal2.LoadEnviroMap("models/spitfire/enviro.bmp");
ModelNormal2.Sca = F_Scale;
ModelNormal2.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));
//destroy model
//-------------
ModelDestroyed.Specular = true;
ModelDestroyed.Normals = false;
ModelDestroyed.SmoothShading = false;
ModelDestroyed.InitializeAse(1,"models/spitfire/spitfire.ase");
ModelDestroyed.LoadAse(0,"models/spitfire/spitfire.ase");
ModelDestroyed.LoadTexture("models/spitfire/spitfiredestroy.bmp",GetColor(0.0f,1.0f,0.0f));
ModelDestroyed.Sca = F_Scale;
ModelDestroyed.SetMaterial(GetMaterial(GetColor(0.3f,0.3f,0.3f),
GetColor(1.0f,1.0f,1.0f),
GetColor(0.5f,0.5f,0.5f),
GetColor(0.2f,0.2f,0.2f),5.0f));
//model pre vrhanie stencil tienov
//---------------------------------
ModelShadow.OnlyShadow = true;
ModelShadow.Normals = false;
ModelShadow.SmoothShading = false;
ModelShadow.InitializeAse(1,"models/spitfire/spitfireshadow.ase");
ModelShadow.LoadAse(0,"models/spitfire/spitfireshadow.ase");
ModelShadow.Sca = F_Scale;
//model vrtuly
//---------------------------------
ModelVrtula.Specular = true;
ModelVrtula.Normals = false;
ModelVrtula.SmoothShading = false;
ModelVrtula.Lighting = false;
ModelVrtula.Color = GetColor(0.3f,0.6f,0.6f,0.6f);
ModelVrtula.InitializeAse(1,"models/vrtula/vrtula.ase");
ModelVrtula.LoadAse(0,"models/vrtula/vrtula.ase");
ModelVrtula.LoadTexture("models/vrtula/vrtula.bmp",GetColor(1.0f,0.0f,1.0f));
ModelVrtula.Sca = Get3D(1.05f,1.05f,1.05f);
ModelVrtula.SetMaterial(GetMaterial(GetColor(0.3f,0.3f,0.3f),
GetColor(1.0f,1.0f,1.0f),
GetColor(0.5f,0.5f,0.5f),
GetColor(0.2f,0.2f,0.2f),5.0f));
//model kabina
//---------------------------------
ModelKabina.Normals = false;
ModelKabina.SmoothShading = false;
ModelKabina.Lighting = false;
ModelKabina.Color = GetColor(0.5f,1.0f,1.0f,1.0f);
ModelKabina.InitializeAse(1,"models/spitfire/Kabina.ase");
ModelKabina.LoadAse(0,"models/spitfire/Kabina.ase");
ModelKabina.LoadTexture("models/spitfire/Kabina.bmp",GetColor(1.0f,0.0f,1.0f));
ModelKabina.Sca = F_Scale;
//gulky
//--------------
Bullet.Initialize();
Bullet.Friendly = true;
//bomby
//----------------
Bomb.Initialize();
Bomb.Friendly = true;
BulletFire.Initialize(5,1);
BulletFire.AddFrame(0,"particles/fire.bmp",GetColor(1.0f,0.0f,0.0f,0.0f));
BulletAlpha = 0.0f;
Bullet1Rot = 0.0f;
Bullet2Rot = 0.0f;
//Screens
//-----------------
BackGround.Create((float)Engine.Width+10 ,(float)Engine.Height+10,1);
BackGround.AddFrame("menu/background.bmp",GetColor(1,0,1,0));
MsgBack.Create(512,64,1);
MsgBack.AddFrame("menu/gui/msgback.bmp",GetColor(0,1,0,1));
Font.Create(30,FW_BOLD,"Arial");
MFont.Create(18,FW_BOLD,"Arial");
SmallFont.Create(15,FW_BOLD,"Arial");
//zvuk
//-------------
if (SoundEnabled3D == 1)
{
Sound.InitialiseForWavMidi3D();
Sound.LoadSound("sounds/spitfire.wav");
}
else
{
Sound.InitialiseForWavMidi();
Sound.LoadSound("sounds/spitfire.wav");
}
ShowCompas = true;
ShowFPS = false;
ShowMap = true;
ShowKokpit = false;
//reset hodnot
//------------
Reset();
}
//reset hodnot - na konci kazdej hry
//----------------------------------------------------------
void SPITFIRE::Reset()
{
Life = 100;
Speed = (SpitFire_MaxSpeed+SpitFire_MinSpeed)/2.0f;
Score = 0;
Bombs = 0;
FakeScore = 0;
ModelMode = 0;
BulletActive = true;
SoundPlay = false;
BkTime = 1.0f;
InMode = true;
OutMode = false;
ComMode = false;
FaiMode = false;
ScoMode = false;
MessageLifeTime = 0.0f;
MessageOnTime = -1.0f;
strcpy(MessageBuffer,"");
Bullet.Reset();
BulletTime = 0.0f;
Bomb.Reset();
BombTime = 0.0f;
NormalMode = true;
CrazyMode = false;
DestroyedMode = true;
Pos = Get3D(0.0f,550.0f,0.0f);;
Rot = Get3D(0.0f,0.0f,0.0f);
ConRot = Get3D(0.0f,0.0f,0.0f);
Matrix = GetMatrix(Pos,Rot,F_Scale);
VrtulaRotation = 0.0f;
}
// StopSound - zastavi zvuk
//--------------------------------------------------------------
void SPITFIRE::StopSound()
{
SoundPlay = false;
Sound.Stop();
}
//Refresh
//--------------------------------------------------------------
void SPITFIRE::Refresh()
{
//---------
//Ovladanie
//---------
if (NormalMode == true && Menu.EnabledBriefring == false)
{
//mys - lietadlo
float MouseStepX,JoyStepX;
float MouseStepY,JoyStepY;
MouseStepX = Input.MouseRelative.X;
MouseStepY = Input.MouseRelative.Y;
JoyStepX = Input.JoyX;
JoyStepY = Input.JoyY;
if (JoyEnabled) ConRot.Z = -JoyStepX ;
else ConRot.Z -= MouseStepX / ((1000.0f*((10-MouseX)/10.0f))+200.0f);
//ovladanie klavesnica
if (Input.KeyDOWN[DIK_A] == true)
ConRot.Z += Power(MouseX/100.0f);
if (Input.KeyDOWN[DIK_D] == true)
ConRot.Z -= Power(MouseX/100.0f);
if (Invert)
{
if (Input.KeyDOWN[DIK_W] == true == true)
ConRot.X -= Power(MouseY/100.0f);
if (Input.KeyDOWN[DIK_S] == true)
ConRot.X += Power(MouseY/100.0f);
}
else
{
if (Input.KeyDOWN[DIK_W])
ConRot.X += Power(MouseY/100.0f);
if (Input.KeyDOWN[DIK_S])
ConRot.X -= Power(MouseY/100.0f);
}
//obmedzenie vysky
if (Pos.Y > F_MapHeight)
ConRot.X += Power(0.04f);
else
{
if (Invert)
{
if (JoyEnabled) ConRot.X = JoyStepY;
else ConRot.X += MouseStepY / ((2000.0f*((10-MouseY)/10.0f))+200.0f);
}
else
{
if (JoyEnabled) ConRot.X = -JoyStepY;
else ConRot.X -= MouseStepY / ((2000.0f*((10-MouseY)/10.0f))+200.0f);
}
}
//obmedzenie
if (ConRot.X > 1.2f)
ConRot.X = 1.2f;
if (ConRot.X < -1.2f)
ConRot.X = -1.2f;
if (ConRot.Z > 1.4f)
ConRot.Z = 1.4f;
if (ConRot.Z < -1.4f)
ConRot.Z = -1.4f;
Rot.X = ConRot.X;
Rot.Z = ConRot.Z;
//y natocenie
Rot.Y -= Power(sinf(Rot.Z)*0.05f);
//strelba
BulletTime += PowerTime(1.0f);
if (BulletAlpha>0.0f) BulletAlpha -= Power(0.15f);
if((Input.MouseLeftDown == true || Input.KeyDOWN[DIK_DELETE] == true ||
(JoyEnabled && Input.JoyButton1Down)) &&
(BulletTime > SpitFire_BulletFreq) && BulletActive)
{
//vyousti bullet
Bullet.SpawnBullet(BL,Rot);
Bullet.SpawnBullet(BR,Rot);
Explo.SpawnBullet(BL);
Explo.SpawnBullet(BR);
BulletTime = 0.0f;
BulletAlpha = 0.75f;
Bullet1Rot = RandomMinMax(-1.57f,1.57f);
Bullet2Rot = RandomMinMax(-1.57f,1.57f);
//zvuk
SoundLib.FireFriendly.SetPosition(Pos,FireFriendly_Scale);
SoundLib.FireFriendly.Play();
}
//bomby
BombTime += PowerTime(1.0f);
if ((Input.MouseRightDown == true || Input.KeyDOWN[DIK_END] == true||
(Input.JoyButton2Down && JoyEnabled))&&
(BombTime > SpitFire_BombFreq)&&(Bombs > 0))
{
Bomb.SpawnBomb(SpitFire.Pos,SpitFire.Rot,SpitFire.Speed);
BombTime = 0.0f;
Bombs--;
}
//rychlost
if (Input.KeyDOWN[DIK_RSHIFT] == true ||
Input.KeyDOWN[DIK_LSHIFT] == true)
{
if (Speed < SpitFire_MaxSpeed)
Speed += Power(0.1f);
}
if (Input.KeyDOWN[DIK_RCONTROL] == true ||
Input.KeyDOWN[DIK_LCONTROL] == true)
{
if (Speed > SpitFire_MinSpeed)
Speed -= Power(0.1f);
}
//Kompas
if (Input.KeyPRESS[DIK_K] == true)
{
ShowCompas = !ShowCompas ;
}
//Mapa
if (Input.KeyPRESS[DIK_M] == true)
{
ShowMap = !ShowMap;
}
//FPS
if (Input.KeyPRESS[DIK_F] == true)
{
ShowFPS = !ShowFPS;
}
//Kokpit
if (Input.KeyPRESS[DIK_C] == true)
{
ShowKokpit = !ShowKokpit ;
}
}
//briefring
if (Input.KeyPRESS[DIK_ESCAPE] == true)
{
//spusti briefring
Menu.EnabledBriefring = true;
}
//-------------------------------------
//vypocitanie matice podla ktorej sa posunie
//------------------------------------
Matrix = GetMatrix(Pos,Rot,F_Scale);
//-------------
//Sledovaci bod
//-------------
SlPoint = TransformPoint(Get3D(0.0f,0.0f,80.0f),
Matrix);
//---------
//posunutie
//---------
if (NormalMode || CrazyMode)
{
//posun
Pos = TransformPoint(Get3D(0.0f,0.0f,Power(Speed)),
Matrix);
}
//-------------------------------------
//vypocitanie matice a koliznych bodov
//------------------------------------
Matrix = GetMatrix(Pos,Rot,F_Scale);
//kolizne body
PL = SpitFire_Left;
PR = SpitFire_Right;
PU = SpitFire_Up;
PD = SpitFire_Down;
PF = SpitFire_Front;
PB = SpitFire_Back;
PL = TransformPoint(PL,Matrix);
PR = TransformPoint(PR,Matrix);
PB = TransformPoint(PB,Matrix);
PF = TransformPoint(PF,Matrix);
PU = TransformPoint(PU,Matrix);
PD = TransformPoint(PD,Matrix);
//gulomety
BL = TransformPoint(SpitFire_BulletLeft,Matrix);
BR = TransformPoint(SpitFire_BulletRight,Matrix);
//vrtula
PV = TransformPoint(SpitFire_VrtulaPoint,Matrix);
//----------------
//camera
//----------------
SetCamera();
//-------------
//Zvuk motora
//-------------
if (NormalMode || CrazyMode)
{
Sound.SetPosition(Pos,SpitFire_SoundScale);
if (SoundPlay == false && Menu.EnabledBriefring == false)
{
SoundPlay = true;
Sound.Play(true);
}
}
//----------------
//kolizie
//----------------
bool GroundCollision = GetGroundCollision();
//-------------
//process
//-------------
if (NormalMode)
{
//kolizia zo zemov
if (GroundCollision == true)
{
//particle
Explo.SpawnExplosion(Pos);
Explo.SpawnParticle(Pos);
DestroyedMode = true;
NormalMode = false;
Life = -2;
//zvuk
SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
SoundLib.ExplodeLarge.Play();
}
//zivoty
if (Life <= 0)
{
//particle
Explo.SpawnExplosion(Pos);
Explo.SpawnParticle(Pos);
CrazyMode = true;
NormalMode = false;
//zvuk
SoundLib.ExplodeSmall.SetPosition(Pos,ExplodeSmall_Scale);
SoundLib.ExplodeSmall.Play();
}
}
else if(CrazyMode)
{
//kolizia zo zemov
if (GroundCollision == true)
{
//particle
Explo.SpawnExplosion(Pos);
Explo.SpawnParticle(Pos);
DestroyedMode = true;
CrazyMode = false;
//zvuk
SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
SoundLib.ExplodeLarge.Play();
}
//crazy
Rot.Z += Power(0.1f);
Rot.X += Power(0.005f);
Pos.Y -= Power(2.0f);
//particle
Explo.SpawnSmokePlane(Pos);
Explo.SpawnSmokeHit(Pos);
}
else if(DestroyedMode)
{
MissionFailed();
Explo.SpawnSmokeGround(Pos);
}
}
//misia kompletna
//--------------------------------------------------------
void SPITFIRE::MissionCompleted()
{
//zapise novy array
if (ComMode == false && FaiMode == false && OutMode == false)
{
Menu.SaveArray(Level.LevelIndex+1);
}
OutMode = true;
ComMode = true;
}
//misia kompletna
//--------------------------------------------------------
void SPITFIRE::MissionExit()
{
OutMode = true;
FaiMode = false;
}
//misia failed
//--------------------------------------------------------
void SPITFIRE::MissionFailed()
{
if (Level.LevelIndex > 0)
{
if (OutMode == false) FaiMode = true;
OutMode = true;
}
if (Level.LevelIndex == 0)
{
ScoMode = true;
}
}
//vyrenderuje oznamy pre hraca alebo obrazovky
//--------------------------------------------------------
void SPITFIRE::DrawScreens()
{
if (TopScore < SpitFire.Score && Level.LevelIndex == 0)
TopScore = SpitFire.Score;
//naliehava sprava
if (Level.StageTime < MessageOnTime + MessageLifeTime)
{
if (MsgBack.Color.A < 1.0f) MsgBack.Color.A += Power(0.05f);
MsgBack.Pos = Get3D(Engine.Width/2.0f,Engine.Height-130.0f,0.0f);
Engine.SetBlendTrans();
MsgBack.Render();
Engine.SetBlendNone();
if (MsgBack.Color.A > 0.3f && MsgBack.Color.A < 0.4f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"M");
if (MsgBack.Color.A > 0.4f && MsgBack.Color.A < 0.5f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Me");
if (MsgBack.Color.A > 0.5f && MsgBack.Color.A < 0.6f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Mes");
if (MsgBack.Color.A > 0.6f && MsgBack.Color.A < 0.7f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Mess");
if (MsgBack.Color.A > 0.7f && MsgBack.Color.A < 0.8f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Messa");
if (MsgBack.Color.A > 0.8f && MsgBack.Color.A < 0.9f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Messag");
if (MsgBack.Color.A > 0.9f && MsgBack.Color.A < 2.0f)
MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Message:");
if (MsgBack.Color.A > 1.0f)
MFont.Print(Engine.Width/2-140,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),MessageBuffer);
}
else
{
if (MsgBack.Color.A > 0.0f) MsgBack.Color.A -= Power(0.05f);
MsgBack.Pos = Get3D(Engine.Width/2.0f,Engine.Height - 130.0f,0.0f);
Engine.SetBlendTrans();
MsgBack.Render();
Engine.SetBlendNone();
MessageOnTime = -1.0f;
MessageLifeTime = 0.0f;
}
//backtobattle
if ((Pos.X < -SpitFire_MapSize || Pos.X > SpitFire_MapSize) ||
(Pos.Y < -SpitFire_MapSize || Pos.Y > SpitFire_MapSize) ||
(Pos.Z < -SpitFire_MapSize || Pos.Z > SpitFire_MapSize))
{
if (((Pos.X < -F_MapSize || Pos.X > F_MapSize) ||
(Pos.Y < -F_MapSize || Pos.Y > F_MapSize) ||
(Pos.Z < -F_MapSize || Pos.Z > F_MapSize)))
{
MissionFailed();
//ak je battle restart
if (Level.LevelIndex == 0)
{
Level.StartGame(Level.LevelIndex);
SpitFire.BulletTime = -400.0f; //aby nestrielal
}
}
else
{
if (!FaiMode && !ComMode && !ScoMode)
{
if (Language == 0)
Font.Print((int)(Engine.Width/2.0f-230.0f),(int)(Engine.Height/2.0f+75),
GetColor(1.0f,1.0f,0.0f),"YOU MUSS FLY BACK INTO BATTLE");
if (Language == 1)
Font.Print((int)(Engine.Width/2.0f-180.0f),(int)(Engine.Height/2.0f+75),
GetColor(1.0f,1.0f,0.0f),"MUS═è LET╠T ZP╠T DO BOJE");
}
}
}
//font
if (FaiMode) //misia neuspesna
{
if (Language == 0)
Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
GetColor(1.0f,0.0f,0.0f),"MISSION FAILED");
if (Language == 1)
Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
GetColor(1.0f,0.0f,0.0f),"MISE NE┌SP╠èN┴");
if (ComMode) ComMode = false;
if (ScoMode) ScoMode = false;
}
if (ComMode) //misia uspesna
{
if (Language == 0)
Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
GetColor(0.0f,1.0f,0.0f),"MISSION COMPLETED");
if (Language == 1)
Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
GetColor(0.0f,1.0f,0.0f),"MISE ┌SP╠èN┴");
}
if (ScoMode) //tvoje score
{
char cBuf[80];
if (Language == 0) sprintf(cBuf,"YOUR SCORE: %d",SpitFire.Score);
if (Language == 1) sprintf(cBuf,"TVOJE SCORE: %d",SpitFire.Score);
Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
GetColor(1.0f,1.0f,0.0f),cBuf);
if (Language == 0) sprintf(cBuf,"You can upload score on internet from start menu or game directory");
if (Language == 1) sprintf(cBuf,"M∙₧ete nahrßt svΘ sk≤re na Internet z nabφdky Start nebo z adresß°e se hrou");
SmallFont.PrintCenter(0,(int)(Engine.Height/2.0f+103),
GetColor(1.0f,1.0f,0.0f),cBuf);
}
//background
if (InMode)
{
BkTime -= Power(0.02f);
if (BkTime < 0.0f)
{
InMode = false;
Menu.EnabledBriefring = true;
}
}
if (OutMode)
{
BkTime += Power(0.015f);
if(BkTime > 1.0f)
{
Menu.EnabledMenu = true;
Level.StopAllSounds();
if(FaiMode)
{
Level.StartGame(Level.LevelIndex);
//aby spitfire nestrielal
SpitFire.BulletTime = -400.0f;
Menu.EnabledMenu = false;
}
}
}
if (InMode || OutMode)
{
Engine.SetBlendTrans();
BackGround.Center(Get3D(0.5f,0.5f,0.0f));
BackGround.Color = GetColor(BkTime,1.0f,1.0f,1.0f);
BackGround.Render();
Engine.SetBlendNone();
}
}
//vyrenderuje + tien lietadla
//--------------------------------------------------------
void SPITFIRE::Render1()
{
//----------
//Render
//-----------
//stencil svetlo
StencilShadow.LightPosition.X = Pos.X + 200.0f;
StencilShadow.LightPosition.Y = Pos.Y + 4000.0f;
StencilShadow.LightPosition.Z = Pos.Z + 200.0f;
//Naboje
Bullet.Refresh();
//bomby
Bomb.Refresh();
//Normal
if ((NormalMode)||(CrazyMode))
{
//shadow
if (Shadows == 1)
{
ModelShadow.Pos = Pos;
ModelShadow.Rot = Rot;
ModelShadow.Render();
ModelShadow.BuildShadow(&StencilShadow);
}
//aircraft
if (ModelMode == 1)
{
ModelNormal1.Pos = Pos;
ModelNormal1.Rot = Rot;
ModelNormal1.Render();
}
if (ModelMode == 2)
{
ModelNormal2.Pos = Pos;
ModelNormal2.Rot = Rot;
ModelNormal2.Render();
}
if (ModelMode == 3)
{
ModelLib.MesserSchmitt_ModelNormal.Pos = Pos;
ModelLib.MesserSchmitt_ModelNormal.Rot = Rot;
ModelLib.MesserSchmitt_ModelNormal.Render();
}
//kabina
if (ModelMode == 1 || ModelMode == 2)
{
Engine.SetBlendTrans();
ModelKabina.Rot = Rot;
ModelKabina.Pos = Pos;
ModelKabina.Render();
Engine.SetBlendNone();
}
}
//destroyed
else if(DestroyedMode)
{
if (Shadows == 1)
{
ModelShadow.Pos = Pos;
ModelShadow.Rot = Rot;
ModelShadow.Render();
ModelShadow.BuildShadow(&StencilShadow);
}
ModelDestroyed.Pos = Pos;
ModelDestroyed.Rot = Rot;
ModelDestroyed.Render();
}
}
//render particles
//-------------------------------------------------------
void SPITFIRE::Render2()
{
if (NormalMode)
{
//render bullet fire
Engine.SetBlendCustom(D3DBLEND_SRCCOLOR,D3DBLEND_ONE);
BulletFire.RenderParticle(BL,
GetColor(BulletAlpha,BulletAlpha,BulletAlpha,BulletAlpha),
7.0f,
Bullet1Rot,
0.0f);
BulletFire.RenderParticle(BR,
GetColor(BulletAlpha,BulletAlpha,BulletAlpha,BulletAlpha),
7.0f,
Bullet2Rot,
0.0f);
BulletFire.Render();
Engine.SetBlendNone();
//vrtula
VrtulaRotation += Power((Speed-5.0f)/15.0f);
ModelVrtula.Pos = PV;
ModelVrtula.Rot = Rot;
Engine.SetBlendTrans();
Engine.SetAlphaTest(true);
ModelVrtula.Rot.Z = VrtulaRotation;
ModelVrtula.Render();
Engine.SetBlendNone();
}
}
//camera
//-------------------------------------------------------
void SPITFIRE::SetCamera()
{
//-------------
//Camera
//-------------
D3DXMATRIX CamMat = GetMatrix(Pos,Rot,F_Scale);
if (NormalMode )
{
if ((ShowKokpit || Input.KeyDOWN[DIK_DOWN] == true ) &&
ModelMode != 3)
{
Camera.Pos = TransformPoint(Get3D(0.0f,12.0f,-9.0f),CamMat);
Camera.Rot.X = -SpitFire.Rot.X;
Camera.Rot.Z = SpitFire.Rot.Z;
Camera.Rot.Y = SpitFire.Rot.Y;
Camera.RefreshYawPitchRoll();
}
else if (Input.KeyDOWN[DIK_UP] == true )
{
Camera.ActPos = TransformPoint(Get3D(0.0f,0.0f,320.0f),CamMat);
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
else if (Input.KeyDOWN[DIK_LEFT] == true )
{
Camera.ActPos = TransformPoint(Get3D(-150.0f,60.0f,100.0f),CamMat);
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
else if (Input.KeyDOWN[DIK_RIGHT] == true )
{
Camera.ActPos = TransformPoint(Get3D(150.0f,60.0f,100.0f),CamMat);
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
else if (0)
{
Camera.ActPos = Get3D(0.0f,360.0f,0.0f);
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
else
{
Camera.ActPos = TransformPoint(Get3D(0.0f,41.0f,-50.0f),CamMat);
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
}
else if(CrazyMode)
{
Camera.ActPos = TransformPoint(Get3D(0.0f,0.0f,-160.0f),CamMat);
Camera.ActPos.Y += 60.0f;
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
else if(DestroyedMode)
{
Camera.ActPos.X = Pos.X + 600.0f;
Camera.ActPos.Z = Pos.Z + 600.0f;
Camera.ActPos.Y = Pos.Y + 300.0f;
Camera.Lok = Pos;
Camera.RefreshLookAt();
}
}
//kolizia lietadla zo zemov a objektami
//--------------------------------------------------------
bool SPITFIRE::GetGroundCollision()
{
int i=0;
//Zem
//-------------
if (Level.Krajina.Collise(PD,PU) == true)
{
return true;
}
if (Level.Krajina.Collise(PB,PF) == true)
{
return true;
}
if (Level.Krajina.Collise(PR,PL) == true)
{
Life = -1; //ked sa cuchne kridol len odober zivot
return false;
}
//messerschmitt
//-------------
for (i=0;i<Max_MesserSchmitt;i++)
{
if (Level.MesserSchmitt[i].CollisionDetail(PR,PL) == true)
{
//nastav zivoty ale nevrat koliziu
//lietadlo zacne padat a neostane vovzduchu
Life = -1;
Level.MesserSchmitt[i].Life = -1;
return false;
}
}
//Volker
//-------------
for (i=0;i<Max_Volkers;i++)
{
if (Level.Volker[i].CollisionDetail(PR,PL) == true)
{
//nastav zivoty ale nevrat koliziu
//lietadlo zacne padat a neostane vovzduchu
Life = -1;
Level.Volker[i].Life = -1;
return false;
}
}
//Bombarder
//-------------
for (i=0;i<Max_Bombarders;i++)
{
if ( Level.Bombarder[i].CollisionDetail(PR,PL) == true ||
Level.Bombarder[i].CollisionDetail(PB,PF) == true )
{
//nastav zivoty ale nevrat koliziu
//lietadlo zacne padat a neostane vovzduchu
Life = -1;
return false;
}
}
//structures
//-------------
for (i=0;i<Max_Structures;i++)
{
if (Level.Structure[i].CollisionDetail(PR,PL) == true)
{
Life = -1;
return false;
}
if( Level.Structure[i].CollisionDetail(PD,PU) == true ||
Level.Structure[i].CollisionDetail(PB,PF) == true)
{
Level.Structure[i].Destroyed = true;
Level.Structure[i].Normal = false;
Life = -1;
return true;
}
}
//trucks
//-------------
for (i=0;i<Max_Trucks;i++)
{
if (Level.Truck[i].CollisionDetail(PR,PL) == true )
{
Level.Truck[i].DestroyedMode = true;
Level.Truck[i].NormalMode = false;
Life = -1;
return true;
}
}
return false;
}
//message - vytlaci spravu o zmene ciela
//-------------------------------------------------------------
void SPITFIRE::DrawMessage(char *MessageEng,char *MessageCze,float LifeTime)
{
if (Language == 0) strcpy(MessageBuffer,MessageEng);
if (Language == 1) strcpy(MessageBuffer,MessageCze);
MessageLifeTime = LifeTime;
MessageOnTime = Level.StageTime;
}
//kolizia
//-------------------------------------------------------------
bool SPITFIRE::CollisionBox(VECTOR3D P1, VECTOR3D P2)
{
return ModelNormal1.CollisionBox(P1,P2,Matrix);
}
//kolizia
//-------------------------------------------------------------
bool SPITFIRE::CollisionDetail(VECTOR3D P1, VECTOR3D P2)
{
return ModelNormal1.CollisionDetail(P1,P2,Matrix);
}