home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 July & August / PCWorld_2006-07-08_cd.bin / temacd / planearcade / planearcade.exe / Tank3.bmp / explo.cpp < prev    next >
C/C++ Source or Header  |  2004-11-10  |  12KB  |  451 lines

  1.  
  2. #include "main.h"
  3.  
  4. //------------------------
  5. //Global
  6. //------------------------
  7. EXPLO Explo;
  8.  
  9.  
  10. //inicializacia vybuchov
  11. //----------------------------------------------------------
  12. void EXPLO::Initialize()
  13. {
  14.  
  15.     //ak niesu zapnute particle effekty nerenderuj
  16.     if (ParticleEffects == 0)
  17.         return;
  18.  
  19.     ////////////
  20.     //PARTICLE//
  21.     ////////////
  22.  
  23.     //P_Smoke
  24.     //---------
  25.     P_Smoke.Initialize(1000,1);
  26.     P_Smoke.AddFrame(0,"particles/smoke.bmp",GetColor(1.0f,0.0f,0.0f,0.0f));
  27.  
  28.     //P_SmokeBomb
  29.     //-----------
  30.     P_SmokeBomb.Initialize(500,1);
  31.     P_SmokeBomb.AddFrame(0,"particles/bomb.bmp",GetColor(1.0f,0.0f,0.0f,0.0f));
  32.  
  33.  
  34.     //P_Explosion
  35.     //-----------
  36.     P_Explosion.Initialize(1000,10);
  37.     
  38.     P_Explosion.AddFrame(0,"particles/ex0001.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  39.     P_Explosion.AddFrame(1,"particles/ex0002.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  40.     P_Explosion.AddFrame(2,"particles/ex0003.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  41.     P_Explosion.AddFrame(3,"particles/ex0004.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  42.     P_Explosion.AddFrame(4,"particles/ex0005.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  43.     P_Explosion.AddFrame(5,"particles/ex0006.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  44.     P_Explosion.AddFrame(6,"particles/ex0007.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  45.     P_Explosion.AddFrame(7,"particles/ex0008.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  46.     P_Explosion.AddFrame(8,"particles/ex0009.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  47.     P_Explosion.AddFrame(9,"particles/ex0010.jpg",GetColor(1.0f,0.0f,0.0f,0.0f));
  48.  
  49.     //P_Hit
  50.     //---------
  51.     P_Hit.Initialize(500,1);
  52.     P_Hit.AddFrame(0,"particles/hit.bmp",GetColor(1.0f,0.0f,0.0f,0.0f));
  53.  
  54.     //P_Bullet
  55.     //---------
  56.     P_Bullet.Initialize(300,1);
  57.     P_Bullet.AddFrame(0,"particles/bullet.bmp",GetColor(1.0f,1.0f,0.0f,1.0f));
  58.  
  59.     //P_Particle
  60.     //---------
  61.     P_Particle.Initialize(1000,1);
  62.     P_Particle.AddFrame(0,"particles/particle.bmp",GetColor(1.0f,1.0f,0.0f,1.0f));
  63.  
  64.  
  65.     //////////////////
  66.     //PARTICLESYSTEM//
  67.     //////////////////
  68.  
  69.     //-------------
  70.     //S_SmokeGround
  71.     //-------------
  72.     S_SmokeGround.Initialize(&P_Smoke,1000);
  73.     S_SmokeGround.Emitter.Type = EMITTER_POINT;
  74.     S_SmokeGround.Direction = Get3D(0.2f,1.0f,0.2f);
  75.     S_SmokeGround.Gravity = Get3D(0.0f,0.2f,0.0f);
  76.     S_SmokeGround.GravityPower = 0.7f;
  77.     S_SmokeGround.SpawnFreqency = 280.0f;
  78.     S_SmokeGround.SpawnPower = 5.0f;
  79.     S_SmokeGround.DirectionPower = 0.2f;
  80.     S_SmokeGround.SRCColor = GetColor(0.0f,1.0f,1.0f,1.0f);
  81.     S_SmokeGround.SRCSize = 35.0f;
  82.     S_SmokeGround.DSTColor = GetColor(1.0f,0.0f,0.0f,0.0f);
  83.     S_SmokeGround.DSTSize = 70.0f;
  84.     S_SmokeGround.RotationSpeed = 0.035f;
  85.     S_SmokeGround.DirRandFactor = 0.1f;
  86.     S_SmokeGround.CycleLeght = 6000.0f;
  87.  
  88.     //-------------
  89.     //S_SmokePlane
  90.     //-------------
  91.     S_SmokePlane.Initialize(&P_Explosion,1000);
  92.     S_SmokePlane.Emitter.Type = EMITTER_POINT;
  93.     S_SmokePlane.Direction = Get3D(0.0f,0.0f,0.0f);
  94.     S_SmokePlane.Gravity = Get3D(0.0f,0.0f,0.0f);
  95.     S_SmokePlane.GravityPower = 0.0f;
  96.     S_SmokePlane.SpawnFreqency = 70.0f;
  97.     S_SmokePlane.SpawnPower = 0.0f;
  98.     S_SmokePlane.DirectionPower = 0.2f;
  99.     S_SmokePlane.SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
  100.     S_SmokePlane.SRCSize = 20.0f;
  101.     S_SmokePlane.SRCFrame = 4.0f;
  102.     S_SmokePlane.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  103.     S_SmokePlane.DSTSize = 80.0f;
  104.     S_SmokePlane.DSTFrame = 4.0f;
  105.     S_SmokePlane.RotationSpeed = 0.0f;
  106.     S_SmokePlane.DirRandFactor = 0.1f;
  107.     S_SmokePlane.CycleLeght = 6000.0f;
  108.  
  109.     //-------------
  110.     //S_SmokeHit
  111.     //-------------
  112.     S_SmokeHit.Initialize(&P_Hit,500);
  113.     S_SmokeHit.Emitter.Type = EMITTER_POINT;
  114.     S_SmokeHit.Direction = Get3D(0.0f,0.0f,0.0f);
  115.     S_SmokeHit.Gravity = Get3D(0.0f,0.0f,0.0f);
  116.     S_SmokeHit.GravityPower = 0.0f;
  117.     S_SmokeHit.SpawnFreqency = 50.0f;
  118.     S_SmokeHit.SpawnPower = 0.0f;
  119.     S_SmokeHit.DirectionPower = 0.2f;
  120.     S_SmokeHit.SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
  121.     S_SmokeHit.SRCSize = 19.0f;
  122.     S_SmokeHit.SRCFrame = 0.0f;
  123.     S_SmokeHit.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  124.     S_SmokeHit.DSTSize = 37.0f;
  125.     S_SmokeHit.DSTFrame = 0.0f;
  126.     S_SmokeHit.RotationSpeed = 0.0f;
  127.     S_SmokeHit.DirRandFactor = 0.1f;
  128.     S_SmokeHit.CycleLeght = 3000.0f;
  129.  
  130.     //-------------
  131.     //S_SmokeBomb
  132.     //-------------
  133.     S_SmokeBomb.Initialize(&P_SmokeBomb,500);
  134.     S_SmokeBomb.Emitter.Type = EMITTER_POINT;
  135.     S_SmokeBomb.Direction = Get3D(0.0f,0.0f,0.0f);
  136.     S_SmokeBomb.Gravity = Get3D(0.0f,0.0f,0.0f);
  137.     S_SmokeBomb.GravityPower = 0.0f;
  138.     S_SmokeBomb.SpawnFreqency = 60.0f;
  139.     S_SmokeBomb.SpawnPower = 0.0f;
  140.     S_SmokeBomb.DirectionPower = 0.01f;
  141.     S_SmokeBomb.SRCColor = GetColor(0.5f,1.0f,1.0f,1.0f);
  142.     S_SmokeBomb.SRCSize = 5.0f;
  143.     S_SmokeBomb.SRCFrame = 0.0f;
  144.     S_SmokeBomb.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  145.     S_SmokeBomb.DSTSize = 40.0f;
  146.     S_SmokeBomb.DSTFrame = 0.0f;
  147.     S_SmokeBomb.RotationSpeed = 0.0f;
  148.     S_SmokeBomb.DirRandFactor = 0.1f;
  149.     S_SmokeBomb.CycleLeght = 1500.0f;
  150.  
  151.     //-------
  152.     //S_Hit
  153.     //-------
  154.     S_Hit.Initialize(&P_Hit,500);
  155.     S_Hit.Emitter.Type = EMITTER_POINT;
  156.     S_Hit.Direction = Get3D(0.0f,0.0f,0.0f);
  157.     S_Hit.Gravity = Get3D(0.0f,0.0f,0.0f);
  158.     S_Hit.GravityPower = 0.0f;
  159.     S_Hit.SpawnFreqency = 350.0f;
  160.     S_Hit.SpawnPower = 0.0f;
  161.     S_Hit.DirectionPower = 0.0f;
  162.     S_Hit.SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
  163.     S_Hit.SRCSize = 10.0f;
  164.     S_Hit.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  165.     S_Hit.DSTSize = 10.0f;
  166.     S_Hit.RotationSpeed = 0.0f;
  167.     S_Hit.DirRandFactor = 0.1f;
  168.     S_Hit.CycleLeght = 1000.0f;
  169.  
  170.     //-------
  171.     //S_Bullet
  172.     //-------
  173.     S_Bullet.Initialize(&P_Bullet,300);
  174.     S_Bullet.Emitter.Type = EMITTER_POINT;
  175.     S_Bullet.Direction = Get3D(0.0f,0.0f,0.0f);
  176.     S_Bullet.Gravity = Get3D(0.0f,0.0f,0.0f);
  177.     S_Bullet.GravityPower = 0.0f;
  178.     S_Bullet.SpawnFreqency = 350.0f;
  179.     S_Bullet.SpawnPower = 0.0f;
  180.     S_Bullet.DirectionPower = 0.0f;
  181.     S_Bullet.SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
  182.     S_Bullet.SRCSize = 1.6f;
  183.     S_Bullet.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  184.     S_Bullet.DSTSize = 1.6f;
  185.     S_Bullet.RotationSpeed = 0.02f;
  186.     S_Bullet.DirRandFactor = 0.1f;
  187.     S_Bullet.CycleLeght = 2000.0f;
  188.  
  189.     //----------
  190.     //S_Particle
  191.     //----------
  192.     S_Particle.Initialize(&P_Particle,1000);
  193.     S_Particle.Emitter.Type = EMITTER_POINT;
  194.     S_Particle.Direction = Get3D(0.0f,1.0f,0.0f);
  195.     S_Particle.Gravity = Get3D(0.0f,-1.0f,0.0f);
  196.     S_Particle.GravityPower = 0.1f;
  197.     S_Particle.SpawnFreqency = 200.0f;
  198.     S_Particle.SpawnPower = 5.5f;
  199.     S_Particle.DirectionPower = 0.5f;
  200.     S_Particle.SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
  201.     S_Particle.SRCSize = 4.0f;
  202.     S_Particle.SRCFrame = 0.0f;
  203.     S_Particle.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  204.     S_Particle.DSTSize = 4.0f;
  205.     S_Particle.DSTFrame = 0.0f;
  206.     S_Particle.RotationSpeed = 0.1f;
  207.     S_Particle.DirRandFactor = 10.0f;
  208.     S_Particle.CycleLeght = 1500.0f;
  209.  
  210.     //----------
  211.     //S_Explosion
  212.     //----------
  213.     S_Explosion.Initialize(&P_Explosion,1000);
  214.     S_Explosion.Emitter.Type = EMITTER_POINT;
  215.     S_Explosion.Direction = Get3D(0.0f,0.0f,0.0f);
  216.     S_Explosion.Gravity = Get3D(0.0f,0.0f,0.0f);
  217.     S_Explosion.GravityPower = 0.0f;
  218.     S_Explosion.SpawnFreqency = 200.0f;
  219.     S_Explosion.SpawnPower = 0.0f;
  220.     S_Explosion.DirectionPower = 0.0f;
  221.     S_Explosion.SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
  222.     S_Explosion.SRCSize = 40.0f;
  223.     S_Explosion.SRCFrame = 0.0f;
  224.     S_Explosion.DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
  225.     S_Explosion.DSTSize = 150.0f;
  226.     S_Explosion.DSTFrame = 9.0f;
  227.     S_Explosion.RotationSpeed = 0.0f;
  228.     S_Explosion.DirRandFactor = 0.1f;
  229.     S_Explosion.CycleLeght = 1000.0f;
  230.  
  231.  
  232.     //--------
  233.     //F_Plane
  234.     //--------
  235.     F_Plane.Initialize("particles/fireball1.ase",
  236.                        "particles/fireball1.jpg",
  237.                        GetColor(0.0f,0.0f,0.0f));
  238.     F_Plane.SRCScale = Get3D(2.0f,2.0f,2.0f);
  239.     F_Plane.DSTScale = Get3D(20.0f,20.0f,20.0f);
  240.     
  241.     //--------
  242.     //F_Ball
  243.     //--------
  244.     F_Ball.Initialize("particles/fireball2.ase",
  245.                        "particles/fireball2.jpg",
  246.                        GetColor(0.0f,0.0f,0.0f));
  247.     F_Ball.SRCScale = Get3D(2.0f,2.0f,2.0f);
  248.     F_Ball.DSTScale = Get3D(9.0f,9.0f,9.0f);
  249.  
  250. }
  251.  
  252. //redner vybuchov
  253. //----------------------------------------------------------
  254. void EXPLO::Render()
  255. {
  256.  
  257.     //ak niesu zapnute particle effekty nerenderuj
  258.     if (ParticleEffects == 0)
  259.         return;
  260.  
  261.     //S_Explosion
  262.     //-------------
  263.     Engine.SetBlendCustom(D3DBLEND_SRCALPHA,D3DBLEND_ONE);
  264.  
  265.         S_Explosion.ProcessParticles();
  266.         S_Explosion.Render();
  267.  
  268.     Engine.SetBlendNone();
  269.  
  270.     //S_SmokeHit
  271.     //-------------
  272.     Engine.SetBlendTrans();
  273.  
  274.         S_SmokeHit.ProcessParticles();
  275.         S_SmokeHit.Render();
  276.  
  277.     Engine.SetBlendNone();
  278.  
  279.     //S_SmokeBomb
  280.     //-------------
  281.     Engine.SetBlendTrans();
  282.  
  283.         S_SmokeBomb.ProcessParticles();
  284.         S_SmokeBomb.Render();
  285.  
  286.     Engine.SetBlendNone();
  287.  
  288.     //S_SmokePlane
  289.     //-------------
  290.     Engine.SetBlendCustom(D3DBLEND_SRCALPHA,D3DBLEND_ONE);
  291.  
  292.         S_SmokePlane.ProcessParticles();
  293.         S_SmokePlane.Render();
  294.  
  295.     Engine.SetBlendNone();
  296.  
  297.     //S_Hit
  298.     //-------------
  299.     Engine.SetBlendTrans();
  300.  
  301.         S_Hit.ProcessParticles();
  302.         S_Hit.Render();
  303.  
  304.     Engine.SetBlendNone();
  305.  
  306.     //S_Bullet
  307.     //-------------
  308.     Engine.SetBlendTrans();
  309.  
  310.         S_Bullet.ProcessParticles();
  311.         S_Bullet.Render();
  312.  
  313.     Engine.SetBlendNone();
  314.  
  315.     //S_Particle
  316.     //-------------
  317.     Engine.SetBlendTrans();
  318.  
  319.         S_Particle.ProcessParticles();
  320.         S_Particle.Render();
  321.  
  322.     Engine.SetBlendNone();
  323.  
  324.     //S_SmokeGround
  325.     //-------------
  326.     Engine.SetBlendCustom(D3DBLEND_SRCALPHA,D3DBLEND_INVSRCCOLOR);
  327.  
  328.         S_SmokeGround.ProcessParticles();
  329.         S_SmokeGround.Render();
  330.  
  331.     Engine.SetBlendNone();
  332.  
  333.     //F_Ball
  334.     //--------------
  335.     Engine.SetBlendCustom(D3DBLEND_SRCALPHA,D3DBLEND_ONE);
  336.         F_Ball.Refresh();
  337.     Engine.SetBlendNone();
  338.  
  339.     //F_Plane
  340.     //--------------
  341.     Engine.SetBlendCustom(D3DBLEND_SRCALPHA,D3DBLEND_ONE);
  342.         F_Plane.Refresh();
  343.     Engine.SetBlendNone();
  344.  
  345. }
  346.  
  347. //vypusti dym na zemy - zo znicenych budov
  348. //-----------------------------------------------------------
  349. void EXPLO::SpawnSmokeGround(VECTOR3D Pos)
  350. {
  351.     //ak niesu zapnute particle effekty nerenderuj
  352.     if (ParticleEffects == 0)
  353.         return;
  354.  
  355.     S_SmokeGround.Emitter.Position = Pos;
  356.     S_SmokeGround.SpawnParticlesTime(1);
  357.  
  358. }
  359.  
  360. //vypusti dym v lietadle
  361. //-----------------------------------------------------------
  362. void EXPLO::SpawnSmokePlane(VECTOR3D Pos)
  363. {
  364.     //ak niesu zapnute particle effekty nerenderuj
  365.     if (ParticleEffects == 0)
  366.         return;
  367.  
  368.     S_SmokePlane.Emitter.Position = Pos;
  369.     S_SmokePlane.SpawnParticlesTime(1);
  370.  
  371. }
  372.  
  373. //vypusti dym v lietadle
  374. //-----------------------------------------------------------
  375. void EXPLO::SpawnSmokeHit(VECTOR3D Pos)
  376. {
  377.     //ak niesu zapnute particle effekty nerenderuj
  378.     if (ParticleEffects == 0)
  379.         return;
  380.  
  381.     S_SmokeHit.Emitter.Position = Pos;
  382.     S_SmokeHit.SpawnParticlesTime(1);
  383.  
  384. }
  385.  
  386. //vypusti dym v bombe
  387. //-----------------------------------------------------------
  388. void EXPLO::SpawnSmokeBomb(VECTOR3D Pos)
  389. {
  390.     //ak niesu zapnute particle effekty nerenderuj
  391.     if (ParticleEffects == 0)
  392.         return;
  393.  
  394.     S_SmokeBomb.Emitter.Position = Pos;
  395.     S_SmokeBomb.SpawnParticlesTime(1);
  396.  
  397. }
  398.  
  399. //vypusti crepiny z vybuchu
  400. //-----------------------------------------------------------
  401. void EXPLO::SpawnParticle(VECTOR3D Pos)
  402. {
  403.     //ak niesu zapnute particle effekty nerenderuj
  404.     if (ParticleEffects == 0)
  405.         return;
  406.  
  407.     S_Particle.Emitter.Position = Pos;
  408.     S_Particle.SpawnParticles(50);
  409.  
  410. }
  411.  
  412. //vypusti ohnivu gulu
  413. //-----------------------------------------------------------
  414. void EXPLO::SpawnExplosion(VECTOR3D Pos)
  415. {
  416.     //ak niesu zapnute particle effekty nerenderuj
  417.     if (ParticleEffects == 0)
  418.         return;
  419.  
  420.     S_Explosion.Emitter.Position = Pos;
  421.     S_Explosion.SpawnParticles(2);
  422.  
  423.  
  424.  
  425. }
  426.  
  427. //vypusti zasah
  428. //-----------------------------------------------------------
  429. void EXPLO::SpawnHit(VECTOR3D Pos)
  430. {
  431.     //ak niesu zapnute particle effekty nerenderuj
  432.     if (ParticleEffects == 0)
  433.         return;
  434.  
  435.     S_Hit.Emitter.Position = Pos;
  436.     S_Hit.SpawnParticles(1);
  437.  
  438. }
  439.  
  440. //vypusti zasah lietadla
  441. //-----------------------------------------------------------
  442. void EXPLO::SpawnBullet(VECTOR3D Pos)
  443. {
  444.     //ak niesu zapnute particle effekty nerenderuj
  445.     if (ParticleEffects == 0)
  446.         return;
  447.  
  448.     S_Bullet.Emitter.Position = Pos;
  449.     S_Bullet.SpawnParticles(1);
  450.  
  451. }