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 >
C/C++ Source or Header  |  2004-11-27  |  25KB  |  1,034 lines

  1.  
  2. #include "main.h"
  3.  
  4. //-------------
  5. //Global
  6. //-------------
  7. SPITFIRE SpitFire;
  8.  
  9. //Inicializacia
  10. //----------------------------------------------------------
  11. void SPITFIRE::Initialize()
  12. {
  13.  
  14.     //normal model
  15.     //------------
  16.     ModelNormal1.Specular = true;
  17.     ModelNormal1.Normals = false;
  18.     ModelNormal1.SmoothShading = false;
  19.     ModelNormal1.SmoothShading = false;
  20.     ModelNormal1.MultiTexture = true;
  21.     //ModelNormal1.InitializeAse(1,"models/messerschmitt/messerschmitt.ase");
  22.     //ModelNormal1.LoadAse(0,"models/messerschmitt/messerschmitt.ase");
  23.     //ModelNormal1.LoadTexture("models/messerschmitt/messernormal.bmp",GetColor(1.0f,0.0f,1.0f));
  24.     ModelNormal1.InitializeAse(1,"models/spitfire/spitfire.ase");
  25.     ModelNormal1.LoadAse(0,"models/spitfire/spitfire.ase");
  26.     ModelNormal1.LoadTexture("models/spitfire/spitfirenormal1.bmp",GetColor(0.0f,1.0f,0.0f));
  27.     ModelNormal1.LoadEnviroMap("models/spitfire/enviro.bmp");
  28.     ModelNormal1.Sca = F_Scale;
  29.     ModelNormal1.SetMaterial(GetMaterial(GetColor(0.7f,0.7f,0.7f),
  30.                                         GetColor(1.0f,1.0f,1.0f),
  31.                                         GetColor(0.5f,0.5f,0.5f),
  32.                                         GetColor(0.2f,0.2f,0.2f),4.5f));
  33.  
  34.     ModelNormal2.Specular = true;
  35.     ModelNormal2.Normals = false;
  36.     ModelNormal2.SmoothShading = false;
  37.     ModelNormal2.SmoothShading = false;
  38.     ModelNormal2.MultiTexture = true;
  39.     ModelNormal2.InitializeAse(1,"models/spitfire/spitfire.ase");
  40.     ModelNormal2.LoadAse(0,"models/spitfire/spitfire.ase");
  41.     ModelNormal2.LoadTexture("models/spitfire/spitfirenormal2.bmp",GetColor(0.0f,1.0f,0.0f));
  42.     ModelNormal2.LoadEnviroMap("models/spitfire/enviro.bmp");
  43.     ModelNormal2.Sca = F_Scale;
  44.     ModelNormal2.SetMaterial(GetMaterial(GetColor(0.7f,0.7f,0.7f),
  45.                                         GetColor(1.0f,1.0f,1.0f),
  46.                                         GetColor(0.5f,0.5f,0.5f),
  47.                                         GetColor(0.2f,0.2f,0.2f),4.5f));
  48.  
  49.     //destroy model
  50.     //-------------
  51.     ModelDestroyed.Specular = true;
  52.     ModelDestroyed.Normals = false;
  53.     ModelDestroyed.SmoothShading = false;
  54.     ModelDestroyed.InitializeAse(1,"models/spitfire/spitfire.ase");
  55.     ModelDestroyed.LoadAse(0,"models/spitfire/spitfire.ase");
  56.     ModelDestroyed.LoadTexture("models/spitfire/spitfiredestroy.bmp",GetColor(0.0f,1.0f,0.0f));
  57.     ModelDestroyed.Sca = F_Scale;
  58.     ModelDestroyed.SetMaterial(GetMaterial(GetColor(0.3f,0.3f,0.3f),
  59.                                            GetColor(1.0f,1.0f,1.0f),
  60.                                            GetColor(0.5f,0.5f,0.5f),
  61.                                            GetColor(0.2f,0.2f,0.2f),5.0f));
  62.  
  63.  
  64.     //model pre vrhanie stencil tienov
  65.     //---------------------------------
  66.     ModelShadow.OnlyShadow = true;
  67.     ModelShadow.Normals = false;
  68.     ModelShadow.SmoothShading = false;
  69.     ModelShadow.InitializeAse(1,"models/spitfire/spitfireshadow.ase");
  70.     ModelShadow.LoadAse(0,"models/spitfire/spitfireshadow.ase");
  71.     ModelShadow.Sca = F_Scale;
  72.  
  73.     //model vrtuly
  74.     //---------------------------------
  75.     ModelVrtula.Specular = true;
  76.     ModelVrtula.Normals = false;
  77.     ModelVrtula.SmoothShading = false;
  78.     ModelVrtula.Lighting = false;
  79.     ModelVrtula.Color = GetColor(0.3f,0.6f,0.6f,0.6f);
  80.     ModelVrtula.InitializeAse(1,"models/vrtula/vrtula.ase");
  81.     ModelVrtula.LoadAse(0,"models/vrtula/vrtula.ase");
  82.     ModelVrtula.LoadTexture("models/vrtula/vrtula.bmp",GetColor(1.0f,0.0f,1.0f));
  83.     ModelVrtula.Sca = Get3D(1.05f,1.05f,1.05f);
  84.     ModelVrtula.SetMaterial(GetMaterial(GetColor(0.3f,0.3f,0.3f),
  85.                                            GetColor(1.0f,1.0f,1.0f),
  86.                                            GetColor(0.5f,0.5f,0.5f),
  87.                                            GetColor(0.2f,0.2f,0.2f),5.0f));
  88.  
  89.     //model kabina
  90.     //---------------------------------
  91.     ModelKabina.Normals = false;
  92.     ModelKabina.SmoothShading = false;
  93.     ModelKabina.Lighting = false;
  94.     ModelKabina.Color = GetColor(0.5f,1.0f,1.0f,1.0f);
  95.     ModelKabina.InitializeAse(1,"models/spitfire/Kabina.ase");
  96.     ModelKabina.LoadAse(0,"models/spitfire/Kabina.ase");
  97.     ModelKabina.LoadTexture("models/spitfire/Kabina.bmp",GetColor(1.0f,0.0f,1.0f));
  98.     ModelKabina.Sca = F_Scale;
  99.     
  100.     //gulky
  101.     //--------------
  102.     Bullet.Initialize();
  103.     Bullet.Friendly = true;
  104.  
  105.     //bomby
  106.     //----------------
  107.     Bomb.Initialize();
  108.     Bomb.Friendly = true;
  109.  
  110.     BulletFire.Initialize(5,1);
  111.     BulletFire.AddFrame(0,"particles/fire.bmp",GetColor(1.0f,0.0f,0.0f,0.0f));
  112.  
  113.     BulletAlpha = 0.0f;
  114.     Bullet1Rot = 0.0f;
  115.     Bullet2Rot = 0.0f;
  116.  
  117.     //Screens
  118.     //-----------------
  119.     BackGround.Create((float)Engine.Width+10 ,(float)Engine.Height+10,1);
  120.     BackGround.AddFrame("menu/background.bmp",GetColor(1,0,1,0));
  121.  
  122.     MsgBack.Create(512,64,1);
  123.     MsgBack.AddFrame("menu/gui/msgback.bmp",GetColor(0,1,0,1));
  124.  
  125.     Font.Create(30,FW_BOLD,"Arial");    
  126.     MFont.Create(18,FW_BOLD,"Arial");
  127.     SmallFont.Create(15,FW_BOLD,"Arial");
  128.  
  129.     //zvuk
  130.     //-------------
  131.     if (SoundEnabled3D == 1)
  132.     {
  133.         Sound.InitialiseForWavMidi3D();
  134.         Sound.LoadSound("sounds/spitfire.wav");
  135.     }
  136.     else
  137.     {
  138.         Sound.InitialiseForWavMidi();
  139.         Sound.LoadSound("sounds/spitfire.wav");
  140.     }
  141.  
  142.     ShowCompas = true;
  143.     ShowFPS = false;
  144.     ShowMap = true;
  145.     ShowKokpit = false;
  146.     
  147.     //reset hodnot
  148.     //------------
  149.     Reset();
  150.  
  151. }
  152.  
  153. //reset hodnot - na konci kazdej hry
  154. //----------------------------------------------------------
  155. void SPITFIRE::Reset()
  156. {
  157.  
  158.     Life = 100;
  159.     Speed = (SpitFire_MaxSpeed+SpitFire_MinSpeed)/2.0f;
  160.     Score = 0;
  161.     Bombs = 0;
  162.     FakeScore = 0;
  163.     ModelMode = 0;
  164.  
  165.     BulletActive = true;
  166.  
  167.     SoundPlay = false;
  168.     
  169.     BkTime = 1.0f;
  170.     InMode = true;
  171.     OutMode = false;
  172.     ComMode = false;
  173.     FaiMode = false;
  174.     ScoMode = false;
  175.  
  176.     MessageLifeTime = 0.0f;
  177.     MessageOnTime = -1.0f;
  178.     strcpy(MessageBuffer,"");
  179.     
  180.     Bullet.Reset();
  181.     BulletTime = 0.0f;
  182.  
  183.     Bomb.Reset();
  184.     BombTime = 0.0f;
  185.  
  186.     NormalMode = true;
  187.     CrazyMode = false;
  188.     DestroyedMode = true;
  189.  
  190.     Pos = Get3D(0.0f,550.0f,0.0f);;
  191.     Rot = Get3D(0.0f,0.0f,0.0f);
  192.     ConRot = Get3D(0.0f,0.0f,0.0f);
  193.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  194.  
  195.     VrtulaRotation = 0.0f;
  196. }
  197. // StopSound - zastavi zvuk
  198. //--------------------------------------------------------------
  199. void SPITFIRE::StopSound()
  200. {
  201.     SoundPlay = false;
  202.     Sound.Stop();
  203. }
  204.  
  205. //Refresh
  206. //--------------------------------------------------------------
  207. void SPITFIRE::Refresh()
  208. {
  209.     //---------
  210.     //Ovladanie
  211.     //---------
  212.     if (NormalMode == true && Menu.EnabledBriefring == false)
  213.     {
  214.  
  215.         //mys - lietadlo
  216.         float MouseStepX,JoyStepX; 
  217.         float MouseStepY,JoyStepY;
  218.         MouseStepX = Input.MouseRelative.X;
  219.         MouseStepY = Input.MouseRelative.Y;
  220.         JoyStepX = Input.JoyX;
  221.         JoyStepY = Input.JoyY;
  222.     
  223.         if (JoyEnabled) ConRot.Z = -JoyStepX ;
  224.         else ConRot.Z -= MouseStepX / ((1000.0f*((10-MouseX)/10.0f))+200.0f);
  225.             
  226.         //ovladanie klavesnica
  227.         if (Input.KeyDOWN[DIK_A] == true)
  228.             ConRot.Z += Power(MouseX/100.0f);
  229.         if (Input.KeyDOWN[DIK_D] == true)
  230.             ConRot.Z -= Power(MouseX/100.0f);
  231.         if (Invert)
  232.         {
  233.             if (Input.KeyDOWN[DIK_W] == true == true)
  234.                 ConRot.X -= Power(MouseY/100.0f);
  235.             if (Input.KeyDOWN[DIK_S] == true)
  236.                 ConRot.X += Power(MouseY/100.0f);
  237.         }
  238.         else
  239.         {
  240.             if (Input.KeyDOWN[DIK_W])
  241.                 ConRot.X += Power(MouseY/100.0f);
  242.             if (Input.KeyDOWN[DIK_S])
  243.                 ConRot.X -= Power(MouseY/100.0f);
  244.         }
  245.  
  246.         //obmedzenie vysky
  247.         if (Pos.Y > F_MapHeight)
  248.             ConRot.X += Power(0.04f);
  249.         else
  250.         {
  251.             if (Invert)
  252.             {
  253.                 if (JoyEnabled) ConRot.X = JoyStepY;
  254.                 else ConRot.X += MouseStepY / ((2000.0f*((10-MouseY)/10.0f))+200.0f);
  255.             }
  256.             else
  257.             {
  258.                 if (JoyEnabled) ConRot.X = -JoyStepY;
  259.                 else ConRot.X -= MouseStepY / ((2000.0f*((10-MouseY)/10.0f))+200.0f);
  260.             }
  261.         }
  262.  
  263.         //obmedzenie
  264.         if (ConRot.X > 1.2f)
  265.             ConRot.X = 1.2f;
  266.         if (ConRot.X < -1.2f)
  267.             ConRot.X = -1.2f;
  268.         if (ConRot.Z > 1.4f)
  269.             ConRot.Z = 1.4f;
  270.         if (ConRot.Z < -1.4f)
  271.             ConRot.Z = -1.4f;
  272.  
  273.         Rot.X = ConRot.X;
  274.         Rot.Z = ConRot.Z;
  275.  
  276.         //y natocenie
  277.         Rot.Y -= Power(sinf(Rot.Z)*0.05f);
  278.  
  279.         //strelba
  280.         BulletTime += PowerTime(1.0f);
  281.         if (BulletAlpha>0.0f) BulletAlpha -= Power(0.15f);
  282.         
  283.         if((Input.MouseLeftDown == true || Input.KeyDOWN[DIK_DELETE] == true || 
  284.             (JoyEnabled && Input.JoyButton1Down)) &&
  285.            (BulletTime > SpitFire_BulletFreq) && BulletActive)
  286.         {
  287.             //vyousti bullet
  288.             Bullet.SpawnBullet(BL,Rot);
  289.             Bullet.SpawnBullet(BR,Rot);
  290.             Explo.SpawnBullet(BL);
  291.             Explo.SpawnBullet(BR);
  292.             BulletTime = 0.0f;
  293.  
  294.             BulletAlpha = 0.75f;
  295.             Bullet1Rot = RandomMinMax(-1.57f,1.57f);
  296.             Bullet2Rot = RandomMinMax(-1.57f,1.57f);
  297.  
  298.             //zvuk
  299.             SoundLib.FireFriendly.SetPosition(Pos,FireFriendly_Scale);
  300.             SoundLib.FireFriendly.Play();
  301.         }
  302.  
  303.         //bomby
  304.         BombTime += PowerTime(1.0f);
  305.         if ((Input.MouseRightDown == true || Input.KeyDOWN[DIK_END] == true|| 
  306.             (Input.JoyButton2Down && JoyEnabled))&&
  307.             (BombTime > SpitFire_BombFreq)&&(Bombs > 0))    
  308.         {
  309.             Bomb.SpawnBomb(SpitFire.Pos,SpitFire.Rot,SpitFire.Speed);
  310.             BombTime = 0.0f;
  311.             Bombs--;
  312.         }
  313.  
  314.         //rychlost
  315.         if (Input.KeyDOWN[DIK_RSHIFT] == true ||
  316.             Input.KeyDOWN[DIK_LSHIFT] == true)
  317.         {
  318.             if (Speed < SpitFire_MaxSpeed)
  319.                 Speed += Power(0.1f);
  320.  
  321.         }
  322.         if (Input.KeyDOWN[DIK_RCONTROL] == true ||
  323.             Input.KeyDOWN[DIK_LCONTROL] == true)
  324.         {
  325.             if (Speed > SpitFire_MinSpeed)
  326.                 Speed -= Power(0.1f);
  327.         }
  328.  
  329.         //Kompas
  330.         if (Input.KeyPRESS[DIK_K] == true)
  331.         {
  332.             ShowCompas = !ShowCompas ;
  333.         }
  334.         //Mapa
  335.         if (Input.KeyPRESS[DIK_M] == true)
  336.         {
  337.             ShowMap = !ShowMap; 
  338.         }
  339.         //FPS
  340.         if (Input.KeyPRESS[DIK_F] == true)
  341.         {
  342.             ShowFPS = !ShowFPS; 
  343.         }
  344.         //Kokpit
  345.         if (Input.KeyPRESS[DIK_C] == true)
  346.         {
  347.             ShowKokpit = !ShowKokpit ;
  348.         }
  349.         
  350.     }
  351.  
  352.     //briefring
  353.     if (Input.KeyPRESS[DIK_ESCAPE] == true)
  354.     {
  355.         //spusti briefring
  356.         Menu.EnabledBriefring = true;
  357.     }
  358.  
  359.     //-------------------------------------
  360.     //vypocitanie matice podla ktorej sa posunie
  361.     //------------------------------------
  362.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  363.  
  364.     //-------------
  365.     //Sledovaci bod
  366.     //-------------
  367.     SlPoint = TransformPoint(Get3D(0.0f,0.0f,80.0f),
  368.                               Matrix);
  369.  
  370.     //---------
  371.     //posunutie
  372.     //---------
  373.     if (NormalMode || CrazyMode)
  374.     {
  375.  
  376.         //posun
  377.         Pos = TransformPoint(Get3D(0.0f,0.0f,Power(Speed)),
  378.                               Matrix);
  379.     }
  380.  
  381.     //-------------------------------------
  382.     //vypocitanie matice a koliznych bodov
  383.     //------------------------------------
  384.     Matrix = GetMatrix(Pos,Rot,F_Scale);
  385.  
  386.     //kolizne body
  387.     PL = SpitFire_Left;
  388.     PR = SpitFire_Right;
  389.     PU = SpitFire_Up;
  390.     PD = SpitFire_Down;
  391.     PF = SpitFire_Front;
  392.     PB = SpitFire_Back;
  393.  
  394.     PL = TransformPoint(PL,Matrix);
  395.     PR = TransformPoint(PR,Matrix);
  396.     PB = TransformPoint(PB,Matrix);
  397.     PF = TransformPoint(PF,Matrix);
  398.     PU = TransformPoint(PU,Matrix);
  399.     PD = TransformPoint(PD,Matrix);
  400.  
  401.     //gulomety
  402.     BL = TransformPoint(SpitFire_BulletLeft,Matrix);
  403.     BR = TransformPoint(SpitFire_BulletRight,Matrix);
  404.  
  405.     //vrtula
  406.     PV = TransformPoint(SpitFire_VrtulaPoint,Matrix);
  407.  
  408.     //----------------
  409.     //camera
  410.     //----------------
  411.     SetCamera();
  412.  
  413.     //-------------
  414.     //Zvuk motora
  415.     //-------------
  416.     if (NormalMode || CrazyMode)
  417.     {
  418.         Sound.SetPosition(Pos,SpitFire_SoundScale);
  419.         if (SoundPlay == false && Menu.EnabledBriefring == false)
  420.         {
  421.             SoundPlay = true;
  422.             Sound.Play(true);    
  423.         }
  424.     }
  425.  
  426.     //----------------
  427.     //kolizie
  428.     //----------------
  429.     bool GroundCollision = GetGroundCollision();
  430.  
  431.     //-------------
  432.     //process
  433.     //-------------
  434.     if (NormalMode)
  435.     {
  436.         
  437.         //kolizia zo zemov
  438.         if (GroundCollision == true)
  439.         {
  440.  
  441.             //particle
  442.             Explo.SpawnExplosion(Pos);
  443.             Explo.SpawnParticle(Pos);
  444.  
  445.             DestroyedMode = true;
  446.             NormalMode = false;
  447.             Life = -2;
  448.  
  449.             //zvuk
  450.             SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
  451.             SoundLib.ExplodeLarge.Play();
  452.         }
  453.  
  454.         //zivoty
  455.         if (Life <= 0)
  456.         {
  457.             //particle
  458.             Explo.SpawnExplosion(Pos);
  459.             Explo.SpawnParticle(Pos);
  460.  
  461.             CrazyMode = true;
  462.             NormalMode = false;
  463.  
  464.             //zvuk
  465.             SoundLib.ExplodeSmall.SetPosition(Pos,ExplodeSmall_Scale);
  466.             SoundLib.ExplodeSmall.Play();
  467.         }
  468.  
  469.         
  470.     }
  471.     else if(CrazyMode)
  472.     {
  473.  
  474.         //kolizia zo zemov
  475.         if (GroundCollision == true)
  476.         {
  477.             //particle
  478.             Explo.SpawnExplosion(Pos);
  479.             Explo.SpawnParticle(Pos);
  480.  
  481.             DestroyedMode = true;
  482.             CrazyMode = false;
  483.  
  484.             //zvuk
  485.             SoundLib.ExplodeLarge.SetPosition(Pos,ExplodeLarge_Scale);
  486.             SoundLib.ExplodeLarge.Play();
  487.         }
  488.  
  489.         //crazy
  490.         Rot.Z += Power(0.1f);
  491.         Rot.X += Power(0.005f);
  492.         Pos.Y -= Power(2.0f);
  493.  
  494.         //particle
  495.         Explo.SpawnSmokePlane(Pos);
  496.         Explo.SpawnSmokeHit(Pos);
  497.  
  498.     }
  499.     else if(DestroyedMode)
  500.     {
  501.         MissionFailed();    
  502.  
  503.         Explo.SpawnSmokeGround(Pos);
  504.     }
  505.      
  506.  
  507.  
  508. }
  509.  
  510. //misia kompletna
  511. //--------------------------------------------------------
  512. void SPITFIRE::MissionCompleted()
  513. {
  514.     //zapise novy array
  515.     if (ComMode == false && FaiMode == false && OutMode == false)
  516.     {
  517.         Menu.SaveArray(Level.LevelIndex+1);
  518.     }
  519.  
  520.     OutMode = true;
  521.     ComMode = true;
  522. }
  523.  
  524. //misia kompletna
  525. //--------------------------------------------------------
  526. void SPITFIRE::MissionExit()
  527. {
  528.     OutMode = true;
  529.     FaiMode = false;
  530. }
  531.  
  532. //misia failed
  533. //--------------------------------------------------------
  534. void SPITFIRE::MissionFailed()
  535. {
  536.     if (Level.LevelIndex > 0)
  537.     {
  538.         if (OutMode == false) FaiMode = true;
  539.         OutMode = true;
  540.     }
  541.     if (Level.LevelIndex == 0)
  542.     {
  543.         ScoMode = true;
  544.     }
  545. }
  546.  
  547. //vyrenderuje oznamy pre hraca alebo obrazovky
  548. //--------------------------------------------------------
  549. void SPITFIRE::DrawScreens()
  550. {
  551.  
  552.     if (TopScore < SpitFire.Score && Level.LevelIndex == 0)
  553.         TopScore = SpitFire.Score;
  554.  
  555.     //naliehava sprava
  556.     if (Level.StageTime < MessageOnTime + MessageLifeTime)
  557.     {
  558.         
  559.         if (MsgBack.Color.A < 1.0f) MsgBack.Color.A += Power(0.05f);
  560.         MsgBack.Pos = Get3D(Engine.Width/2.0f,Engine.Height-130.0f,0.0f);
  561.         
  562.         Engine.SetBlendTrans();
  563.             MsgBack.Render();
  564.         Engine.SetBlendNone();
  565.  
  566.         if (MsgBack.Color.A > 0.3f && MsgBack.Color.A < 0.4f)
  567.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"M");
  568.         if (MsgBack.Color.A > 0.4f && MsgBack.Color.A < 0.5f)
  569.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Me");
  570.         if (MsgBack.Color.A > 0.5f && MsgBack.Color.A < 0.6f)
  571.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Mes");
  572.         if (MsgBack.Color.A > 0.6f && MsgBack.Color.A < 0.7f)
  573.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Mess");
  574.         if (MsgBack.Color.A > 0.7f && MsgBack.Color.A < 0.8f)
  575.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Messa");
  576.         if (MsgBack.Color.A > 0.8f && MsgBack.Color.A < 0.9f)
  577.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Messag");
  578.         if (MsgBack.Color.A > 0.9f && MsgBack.Color.A < 2.0f)
  579.             MFont.Print(Engine.Width/2-215,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),"Message:");
  580.  
  581.         if (MsgBack.Color.A > 1.0f)
  582.             MFont.Print(Engine.Width/2-140,Engine.Height - 137,GetColor(0.0f,0.0f,0.0f),MessageBuffer);
  583.         
  584.     }
  585.     else
  586.     {
  587.         if (MsgBack.Color.A > 0.0f) MsgBack.Color.A -= Power(0.05f);
  588.         MsgBack.Pos = Get3D(Engine.Width/2.0f,Engine.Height - 130.0f,0.0f);
  589.     
  590.         Engine.SetBlendTrans();
  591.             MsgBack.Render();
  592.         Engine.SetBlendNone();
  593.  
  594.         MessageOnTime = -1.0f;
  595.         MessageLifeTime = 0.0f;
  596.     }
  597.  
  598.     //backtobattle
  599.     if ((Pos.X < -SpitFire_MapSize || Pos.X > SpitFire_MapSize) ||
  600.         (Pos.Y < -SpitFire_MapSize || Pos.Y > SpitFire_MapSize) ||
  601.         (Pos.Z < -SpitFire_MapSize || Pos.Z > SpitFire_MapSize))
  602.     {
  603.  
  604.         if (((Pos.X < -F_MapSize || Pos.X > F_MapSize) ||
  605.         (Pos.Y < -F_MapSize || Pos.Y > F_MapSize) ||
  606.         (Pos.Z < -F_MapSize || Pos.Z > F_MapSize)))
  607.         {
  608.             MissionFailed();
  609.             
  610.             //ak je battle restart
  611.             if (Level.LevelIndex == 0)
  612.             {
  613.                 Level.StartGame(Level.LevelIndex);
  614.                 SpitFire.BulletTime = -400.0f; //aby nestrielal
  615.             }
  616.         }
  617.         else
  618.         {
  619.             if (!FaiMode && !ComMode && !ScoMode)
  620.             {
  621.                 if (Language == 0)
  622.                 Font.Print((int)(Engine.Width/2.0f-230.0f),(int)(Engine.Height/2.0f+75),
  623.                        GetColor(1.0f,1.0f,0.0f),"YOU MUSS FLY BACK INTO BATTLE");
  624.                 if (Language == 1)
  625.                 Font.Print((int)(Engine.Width/2.0f-180.0f),(int)(Engine.Height/2.0f+75),
  626.                         GetColor(1.0f,1.0f,0.0f),"MUS═è LET╠T ZP╠T DO BOJE");
  627.             }
  628.         }
  629.     }
  630.     
  631.     //font
  632.     if (FaiMode) //misia neuspesna
  633.     {
  634.         if (Language == 0)
  635.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  636.                    GetColor(1.0f,0.0f,0.0f),"MISSION FAILED");
  637.     
  638.         if (Language == 1)
  639.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  640.                    GetColor(1.0f,0.0f,0.0f),"MISE NE┌SP╠èN┴");
  641.  
  642.         if (ComMode) ComMode = false;
  643.         if (ScoMode) ScoMode = false;
  644.     }
  645.     if (ComMode) //misia uspesna
  646.     {
  647.         if (Language == 0)
  648.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  649.                    GetColor(0.0f,1.0f,0.0f),"MISSION COMPLETED");
  650.  
  651.         if (Language == 1)
  652.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  653.                    GetColor(0.0f,1.0f,0.0f),"MISE ┌SP╠èN┴");
  654.     }
  655.     if (ScoMode) //tvoje score
  656.     {
  657.         char cBuf[80];
  658.         if (Language == 0) sprintf(cBuf,"YOUR SCORE: %d",SpitFire.Score);
  659.         if (Language == 1) sprintf(cBuf,"TVOJE SCORE: %d",SpitFire.Score);
  660.         Font.PrintCenter(0,(int)(Engine.Height/2.0f+75),
  661.                    GetColor(1.0f,1.0f,0.0f),cBuf);
  662.  
  663.         if (Language == 0) sprintf(cBuf,"You can upload score on internet from start menu or game directory");
  664.         if (Language == 1) sprintf(cBuf,"M∙₧ete nahrßt svΘ sk≤re na Internet z nabφdky Start nebo z adresß°e se hrou");
  665.         SmallFont.PrintCenter(0,(int)(Engine.Height/2.0f+103),
  666.                    GetColor(1.0f,1.0f,0.0f),cBuf);
  667.  
  668.  
  669.     }
  670.  
  671.     
  672.     //background
  673.     if (InMode)
  674.     {
  675.         BkTime -= Power(0.02f);
  676.         if (BkTime < 0.0f)
  677.         {
  678.             InMode = false;
  679.             Menu.EnabledBriefring = true;
  680.         }
  681.     }
  682.     if (OutMode)
  683.     {
  684.         BkTime += Power(0.015f);
  685.         if(BkTime > 1.0f)
  686.         {
  687.             Menu.EnabledMenu = true;
  688.             Level.StopAllSounds();
  689.  
  690.             if(FaiMode)
  691.             {
  692.                 Level.StartGame(Level.LevelIndex);
  693.                 //aby spitfire nestrielal
  694.                 SpitFire.BulletTime = -400.0f;
  695.                 Menu.EnabledMenu = false;
  696.             }
  697.         }
  698.     }
  699.  
  700.     if (InMode || OutMode)
  701.     {    
  702.         Engine.SetBlendTrans();
  703.             BackGround.Center(Get3D(0.5f,0.5f,0.0f));
  704.             BackGround.Color = GetColor(BkTime,1.0f,1.0f,1.0f);
  705.             BackGround.Render();
  706.         Engine.SetBlendNone();
  707.     }
  708.  
  709. }
  710.  
  711. //vyrenderuje + tien lietadla
  712. //--------------------------------------------------------
  713. void SPITFIRE::Render1()
  714. {
  715.  
  716.     //----------
  717.     //Render
  718.     //-----------
  719.  
  720.     //stencil svetlo
  721.     StencilShadow.LightPosition.X = Pos.X + 200.0f;
  722.     StencilShadow.LightPosition.Y = Pos.Y + 4000.0f;
  723.     StencilShadow.LightPosition.Z = Pos.Z + 200.0f;
  724.     
  725.     //Naboje
  726.     Bullet.Refresh();
  727.  
  728.     //bomby
  729.     Bomb.Refresh();
  730.  
  731.     //Normal
  732.     if ((NormalMode)||(CrazyMode))
  733.     {
  734.  
  735.         //shadow
  736.         if (Shadows == 1)
  737.         {
  738.             ModelShadow.Pos = Pos;
  739.             ModelShadow.Rot = Rot;
  740.             ModelShadow.Render();
  741.             ModelShadow.BuildShadow(&StencilShadow);
  742.         }
  743.  
  744.         //aircraft
  745.         if (ModelMode == 1)
  746.         {
  747.             ModelNormal1.Pos = Pos;
  748.             ModelNormal1.Rot = Rot;
  749.             ModelNormal1.Render();
  750.         }
  751.         if (ModelMode == 2)
  752.         {
  753.             ModelNormal2.Pos = Pos;
  754.             ModelNormal2.Rot = Rot;
  755.             ModelNormal2.Render();
  756.         }
  757.         if (ModelMode == 3)
  758.         {
  759.             ModelLib.MesserSchmitt_ModelNormal.Pos = Pos;
  760.             ModelLib.MesserSchmitt_ModelNormal.Rot = Rot;
  761.             ModelLib.MesserSchmitt_ModelNormal.Render();
  762.         }
  763.  
  764.         //kabina
  765.         if (ModelMode == 1 || ModelMode == 2)
  766.         {
  767.             Engine.SetBlendTrans();
  768.                 ModelKabina.Rot = Rot;
  769.                 ModelKabina.Pos = Pos;
  770.                 ModelKabina.Render();
  771.             Engine.SetBlendNone();
  772.         }
  773.     
  774.         
  775.     }
  776.     //destroyed
  777.     else if(DestroyedMode)
  778.     {
  779.         if (Shadows == 1)
  780.         {
  781.             ModelShadow.Pos = Pos;
  782.             ModelShadow.Rot = Rot;
  783.             ModelShadow.Render();
  784.             ModelShadow.BuildShadow(&StencilShadow);
  785.         }
  786.  
  787.         ModelDestroyed.Pos = Pos;
  788.         ModelDestroyed.Rot = Rot;
  789.         ModelDestroyed.Render();
  790.     }
  791.  
  792. }
  793.  
  794. //render particles
  795. //-------------------------------------------------------
  796. void SPITFIRE::Render2()
  797. {
  798.  
  799.     if (NormalMode)
  800.     {
  801.         //render bullet fire
  802.         Engine.SetBlendCustom(D3DBLEND_SRCCOLOR,D3DBLEND_ONE);
  803.             BulletFire.RenderParticle(BL,
  804.                                       GetColor(BulletAlpha,BulletAlpha,BulletAlpha,BulletAlpha),
  805.                                       7.0f,
  806.                                       Bullet1Rot,
  807.                                       0.0f);
  808.             BulletFire.RenderParticle(BR,
  809.                                       GetColor(BulletAlpha,BulletAlpha,BulletAlpha,BulletAlpha),
  810.                                       7.0f,
  811.                                       Bullet2Rot,
  812.                                       0.0f);
  813.             BulletFire.Render();
  814.         Engine.SetBlendNone();
  815.  
  816.         //vrtula
  817.         VrtulaRotation += Power((Speed-5.0f)/15.0f);
  818.  
  819.         ModelVrtula.Pos = PV;
  820.         ModelVrtula.Rot = Rot;
  821.  
  822.         Engine.SetBlendTrans();
  823.         Engine.SetAlphaTest(true);
  824.             ModelVrtula.Rot.Z = VrtulaRotation;
  825.             ModelVrtula.Render();
  826.         Engine.SetBlendNone();
  827.  
  828.     }
  829.  
  830. }
  831.  
  832. //camera
  833. //-------------------------------------------------------
  834. void SPITFIRE::SetCamera()
  835. {
  836.  
  837.     //-------------
  838.     //Camera
  839.     //-------------
  840.     D3DXMATRIX CamMat = GetMatrix(Pos,Rot,F_Scale);
  841.  
  842.     if (NormalMode )
  843.     {
  844.  
  845.         if ((ShowKokpit || Input.KeyDOWN[DIK_DOWN] == true ) && 
  846.              ModelMode != 3)
  847.         {
  848.             Camera.Pos = TransformPoint(Get3D(0.0f,12.0f,-9.0f),CamMat);
  849.             Camera.Rot.X = -SpitFire.Rot.X;    
  850.             Camera.Rot.Z =  SpitFire.Rot.Z;    
  851.             Camera.Rot.Y =  SpitFire.Rot.Y;
  852.             Camera.RefreshYawPitchRoll();
  853.         }
  854.         else if (Input.KeyDOWN[DIK_UP] == true )
  855.         {
  856.             Camera.ActPos = TransformPoint(Get3D(0.0f,0.0f,320.0f),CamMat);    
  857.             Camera.Lok = Pos;
  858.             Camera.RefreshLookAt();
  859.         }
  860.         else if (Input.KeyDOWN[DIK_LEFT] == true )
  861.         {
  862.             Camera.ActPos = TransformPoint(Get3D(-150.0f,60.0f,100.0f),CamMat);    
  863.             Camera.Lok = Pos;
  864.             Camera.RefreshLookAt();
  865.         }
  866.         else if (Input.KeyDOWN[DIK_RIGHT] == true )
  867.         {
  868.             Camera.ActPos = TransformPoint(Get3D(150.0f,60.0f,100.0f),CamMat);    
  869.             Camera.Lok = Pos;
  870.             Camera.RefreshLookAt();
  871.         }
  872.         else if (0)
  873.         {
  874.             Camera.ActPos = Get3D(0.0f,360.0f,0.0f);
  875.             Camera.Lok = Pos;
  876.             Camera.RefreshLookAt();
  877.         }
  878.         else
  879.         {
  880.             Camera.ActPos = TransformPoint(Get3D(0.0f,41.0f,-50.0f),CamMat);    
  881.             Camera.Lok = Pos;
  882.             Camera.RefreshLookAt();
  883.         }
  884.     }
  885.     else if(CrazyMode)
  886.     {
  887.         Camera.ActPos = TransformPoint(Get3D(0.0f,0.0f,-160.0f),CamMat);
  888.         Camera.ActPos.Y += 60.0f;
  889.         Camera.Lok = Pos;
  890.         Camera.RefreshLookAt();
  891.     }
  892.     else if(DestroyedMode)
  893.     {
  894.         Camera.ActPos.X = Pos.X + 600.0f;
  895.         Camera.ActPos.Z = Pos.Z + 600.0f;
  896.         Camera.ActPos.Y = Pos.Y + 300.0f;
  897.         Camera.Lok = Pos;
  898.         Camera.RefreshLookAt();
  899.     }
  900.     
  901.     
  902.  
  903.  
  904. }
  905.  
  906. //kolizia lietadla zo zemov a objektami
  907. //--------------------------------------------------------
  908. bool SPITFIRE::GetGroundCollision()
  909. {
  910.     int i=0;
  911.  
  912.     //Zem
  913.     //-------------
  914.     if (Level.Krajina.Collise(PD,PU) == true)
  915.     {
  916.         return true;
  917.     }
  918.     if (Level.Krajina.Collise(PB,PF) == true)
  919.     {
  920.         return true;
  921.     }
  922.     if (Level.Krajina.Collise(PR,PL) == true)
  923.     {
  924.         Life = -1; //ked sa cuchne kridol len odober zivot
  925.         return false;
  926.     }
  927.  
  928.  
  929.     //messerschmitt
  930.     //-------------
  931.     for (i=0;i<Max_MesserSchmitt;i++)
  932.     {
  933.         if (Level.MesserSchmitt[i].CollisionDetail(PR,PL) == true)
  934.         {
  935.             //nastav zivoty ale nevrat koliziu 
  936.             //lietadlo zacne padat a neostane vovzduchu
  937.             Life = -1;
  938.             Level.MesserSchmitt[i].Life = -1;
  939.             return false;
  940.         }
  941.     }
  942.  
  943.     //Volker
  944.     //-------------
  945.     for (i=0;i<Max_Volkers;i++)
  946.     {
  947.         if (Level.Volker[i].CollisionDetail(PR,PL) == true)
  948.         {
  949.             //nastav zivoty ale nevrat koliziu 
  950.             //lietadlo zacne padat a neostane vovzduchu
  951.             Life = -1;
  952.             Level.Volker[i].Life = -1;
  953.             return false;
  954.         }
  955.     }
  956.  
  957.     //Bombarder
  958.     //-------------
  959.     for (i=0;i<Max_Bombarders;i++)
  960.     {
  961.         if ( Level.Bombarder[i].CollisionDetail(PR,PL) == true ||
  962.              Level.Bombarder[i].CollisionDetail(PB,PF) == true )
  963.         {
  964.             //nastav zivoty ale nevrat koliziu 
  965.             //lietadlo zacne padat a neostane vovzduchu
  966.             Life = -1;
  967.             return false;
  968.         }
  969.     }
  970.     
  971.  
  972.     //structures
  973.     //-------------
  974.     for (i=0;i<Max_Structures;i++)
  975.     {
  976.         if (Level.Structure[i].CollisionDetail(PR,PL) == true)
  977.         {
  978.                     
  979.             Life = -1;
  980.             return false;
  981.         }
  982.  
  983.         if(    Level.Structure[i].CollisionDetail(PD,PU) == true ||
  984.             Level.Structure[i].CollisionDetail(PB,PF) == true)
  985.         {
  986.             Level.Structure[i].Destroyed = true;
  987.             Level.Structure[i].Normal = false;
  988.             
  989.             Life = -1;
  990.             return true;
  991.         }
  992.     }
  993.  
  994.     //trucks
  995.     //-------------
  996.     for (i=0;i<Max_Trucks;i++)
  997.     {
  998.         if (Level.Truck[i].CollisionDetail(PR,PL) == true )
  999.         {
  1000.             Level.Truck[i].DestroyedMode = true;
  1001.             Level.Truck[i].NormalMode = false;
  1002.             
  1003.             Life = -1;
  1004.             return true;
  1005.         }
  1006.     }
  1007.         
  1008.     return false;
  1009.  
  1010. }
  1011.  
  1012. //message - vytlaci spravu o zmene ciela
  1013. //-------------------------------------------------------------
  1014. void SPITFIRE::DrawMessage(char *MessageEng,char *MessageCze,float LifeTime)
  1015. {
  1016.     if (Language == 0)    strcpy(MessageBuffer,MessageEng);
  1017.     if (Language == 1)    strcpy(MessageBuffer,MessageCze);
  1018.     MessageLifeTime = LifeTime;
  1019.     MessageOnTime = Level.StageTime;
  1020. }
  1021.  
  1022. //kolizia
  1023. //-------------------------------------------------------------
  1024. bool SPITFIRE::CollisionBox(VECTOR3D P1, VECTOR3D P2)
  1025. {
  1026.     return ModelNormal1.CollisionBox(P1,P2,Matrix);
  1027. }
  1028.  
  1029. //kolizia
  1030. //-------------------------------------------------------------
  1031. bool SPITFIRE::CollisionDetail(VECTOR3D P1, VECTOR3D P2)
  1032. {
  1033.     return ModelNormal1.CollisionDetail(P1,P2,Matrix);
  1034. }