Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.02 KB | None | 0 0
  1. bool g_IsBoxDestroyedXPlus{ false };
  2. bool g_IsBoxDestroyedXMin{ false };
  3. bool g_IsBoxDestroyedYPlus{ false };
  4. bool g_IsBoxDestroyedYMin{ false };
  5. int g_ValueCWhenDestrXPlus{ g_Player1.ExplosionSize };
  6. int g_ValueCWhenDestrXMin{ g_Player1.ExplosionSize };
  7. int g_ValueCWhenDestrYPlus{ g_Player1.ExplosionSize };
  8. int g_ValueCWhenDestrYMin{ g_Player1.ExplosionSize };
  9.  
  10. void DrawExplosion()//bools and cpos will become arrays
  11. {
  12.     const float offset{ 15 };
  13.     Rectf sourceRect{};
  14.     int columns{}, rows{};
  15.     columns = g_Explosion.currentFrame % g_Explosion.columns;//array
  16.     rows = g_Explosion.currentFrame / g_Explosion.columns;//array
  17.  
  18.     bool ContinueExplosionPlusX{ true };//array
  19.     bool ContinueExplosionMinX{ true };//array
  20.     bool ContinueExplosionMinY{ true };//array
  21.     bool ContinueExplosionPlusY{ true };//array
  22.    
  23.     sourceRect.bottom = (g_Explosion.texture.height / 8) * (rows + 1);//array
  24.     sourceRect.width = g_Explosion.texture.width / g_Explosion.columns;//array
  25.     sourceRect.height = g_Explosion.texture.height / 8;//array
  26.     sourceRect.left = g_Explosion.texture.width / 8 * columns;//array
  27.  
  28.     Point2f pos = g_explosionPos;//array
  29.     /*Center*/DrawTexture(g_Explosion.texture, pos, sourceRect);
  30.     for (int a{ 0 }; a < 12; a++)
  31.     {
  32.         for (int b{ 0 }; b < 19; b++)
  33.         {
  34.             if (g_PlayArea[a][b].pos.x == g_explosionPos.x + 20 && g_PlayArea[a][b].pos.y == g_explosionPos.y + 20)//array
  35.             {
  36.                 for (int c{ 1 }; c <= g_Player1.ExplosionSize; c++)
  37.                 {
  38.                     if (g_PlayArea[a][b + c].IsPlayerTerain == true && ContinueExplosionPlusX == true && g_PlayArea[a][b + c].IsCrate == false && c <= g_ValueCWhenDestrXPlus)//array
  39.                     {
  40.                         pos = g_explosionPos;//array
  41.                         pos.x = pos.x + (float(c * sourceRect.width) / 2 + offset * c);
  42.                         DrawTexture(g_Explosion.texture, pos, sourceRect);//array
  43.                     }
  44.                     else
  45.                     {
  46.  
  47.                         if (g_PlayArea[a][b + c].IsCrate == true && ContinueExplosionPlusX == true)//array
  48.                         {
  49.                             if (g_IsBoxDestroyedXPlus == false)//array
  50.                             {
  51.                                 g_PlayArea[a][b + c].IsCrate = false;
  52.                                 g_IsBoxDestroyedXPlus = true;//array
  53.                                 g_ValueCWhenDestrXPlus = c;//array
  54.                             }
  55.                         }
  56.                         ContinueExplosionPlusX = false;
  57.  
  58.                     }
  59.  
  60.                     if (g_PlayArea[a][b - c].IsPlayerTerain == true && ContinueExplosionMinX == true && g_PlayArea[a][b - c].IsCrate == false && c <= g_ValueCWhenDestrXMin)
  61.                     {
  62.                         pos = g_explosionPos;
  63.                         pos.x = pos.x - (float(c * sourceRect.width) / 2 + offset * c);
  64.                         DrawTexture(g_Explosion.texture, pos, sourceRect);
  65.                     }
  66.                     else
  67.                     {
  68.                         if (g_PlayArea[a][b - c].IsCrate == true && ContinueExplosionMinX == true)
  69.                         {
  70.                             if (g_IsBoxDestroyedXMin == false)
  71.                             {
  72.                                 g_PlayArea[a][b - c].IsCrate = false;
  73.                                 g_IsBoxDestroyedXMin = true;
  74.                                 g_ValueCWhenDestrXMin = c;
  75.                             }
  76.                         }
  77.                         ContinueExplosionMinX = false;
  78.                     }
  79.                     if (g_PlayArea[a + c][b].IsPlayerTerain == true && ContinueExplosionPlusY == true && g_PlayArea[a+c][b].IsCrate == false && c <= g_ValueCWhenDestrYPlus)
  80.                     {      
  81.                         pos = g_explosionPos;
  82.                         pos.y = pos.y + (float(c * sourceRect.height) / 2 + offset * c);
  83.                         DrawTexture(g_Explosion.texture, pos, sourceRect);     
  84.  
  85.                     }
  86.                     else
  87.                     {
  88.                         if (g_PlayArea[a+c][b].IsCrate == true && ContinueExplosionPlusY == true)
  89.                         {
  90.                             if (g_IsBoxDestroyedYPlus == false)
  91.                             {
  92.                                 g_PlayArea[a + c][b].IsCrate = false;
  93.                                 g_IsBoxDestroyedYPlus = true;
  94.                                 g_ValueCWhenDestrYPlus = c;
  95.                             }
  96.                         }
  97.                         ContinueExplosionPlusY = false;
  98.                     }
  99.                     if (g_PlayArea[a - c][b].IsPlayerTerain == true && ContinueExplosionMinY == true && g_PlayArea[a - c][b].IsCrate == false && c <= g_ValueCWhenDestrYMin)
  100.                     {
  101.                         pos = g_explosionPos;
  102.                         pos.y = pos.y - (float(c * sourceRect.height) / 2 + offset * c);
  103.                         DrawTexture(g_Explosion.texture, pos, sourceRect);
  104.                     }
  105.                     else
  106.                     {
  107.                         if (g_PlayArea[a - c][b].IsCrate == true && ContinueExplosionMinY == true)
  108.                         {
  109.                             if (g_IsBoxDestroyedYMin == false)
  110.                             {
  111.                                 g_PlayArea[a - c][b].IsCrate = false;
  112.                                 g_IsBoxDestroyedYMin = true;
  113.                                 g_ValueCWhenDestrYMin = c;
  114.                             }
  115.                         }
  116.                         ContinueExplosionMinY = false;
  117.                     }
  118.                 }
  119.             }
  120.         }
  121.     }
  122. }
  123.  
  124. void UpdateExplosion(float elapsedSec, int indexBomb)// make arrays for all bools/cpositions/sprites
  125. {
  126.    
  127.     g_Explosion.ElapsedTime += elapsedSec;
  128.     if (g_Explosion.ElapsedTime > g_Explosion.SecondsPerFrame)
  129.     {
  130.         if (g_Explosion.currentFrame < g_Explosion.Maxframes)
  131.         {
  132.             ++g_Explosion.currentFrame;
  133.             g_Explosion.ElapsedTime -= g_Explosion.SecondsPerFrame;
  134.         }
  135.         else
  136.         {
  137.             g_Player1Bombs[indexBomb].bombstate = Unplaced;
  138.             g_Explosion.currentFrame = 0;
  139.  
  140.             g_IsBoxDestroyedXPlus = false;
  141.             g_IsBoxDestroyedXMin = false;
  142.             g_IsBoxDestroyedYPlus = false;
  143.             g_IsBoxDestroyedYMin = false;
  144.  
  145.             g_ValueCWhenDestrXPlus = g_Player1.ExplosionSize;
  146.             g_ValueCWhenDestrXMin = g_Player1.ExplosionSize;
  147.             g_ValueCWhenDestrYPlus = g_Player1.ExplosionSize;
  148.             g_ValueCWhenDestrYMin = g_Player1.ExplosionSize;
  149.         }
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement