Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool g_IsBoxDestroyedXPlus{ false };
- bool g_IsBoxDestroyedXMin{ false };
- bool g_IsBoxDestroyedYPlus{ false };
- bool g_IsBoxDestroyedYMin{ false };
- int g_ValueCWhenDestrXPlus{ g_Player1.ExplosionSize };
- int g_ValueCWhenDestrXMin{ g_Player1.ExplosionSize };
- int g_ValueCWhenDestrYPlus{ g_Player1.ExplosionSize };
- int g_ValueCWhenDestrYMin{ g_Player1.ExplosionSize };
- void DrawExplosion()//bools and cpos will become arrays
- {
- const float offset{ 15 };
- Rectf sourceRect{};
- int columns{}, rows{};
- columns = g_Explosion.currentFrame % g_Explosion.columns;//array
- rows = g_Explosion.currentFrame / g_Explosion.columns;//array
- bool ContinueExplosionPlusX{ true };//array
- bool ContinueExplosionMinX{ true };//array
- bool ContinueExplosionMinY{ true };//array
- bool ContinueExplosionPlusY{ true };//array
- sourceRect.bottom = (g_Explosion.texture.height / 8) * (rows + 1);//array
- sourceRect.width = g_Explosion.texture.width / g_Explosion.columns;//array
- sourceRect.height = g_Explosion.texture.height / 8;//array
- sourceRect.left = g_Explosion.texture.width / 8 * columns;//array
- Point2f pos = g_explosionPos;//array
- /*Center*/DrawTexture(g_Explosion.texture, pos, sourceRect);
- for (int a{ 0 }; a < 12; a++)
- {
- for (int b{ 0 }; b < 19; b++)
- {
- if (g_PlayArea[a][b].pos.x == g_explosionPos.x + 20 && g_PlayArea[a][b].pos.y == g_explosionPos.y + 20)//array
- {
- for (int c{ 1 }; c <= g_Player1.ExplosionSize; c++)
- {
- if (g_PlayArea[a][b + c].IsPlayerTerain == true && ContinueExplosionPlusX == true && g_PlayArea[a][b + c].IsCrate == false && c <= g_ValueCWhenDestrXPlus)//array
- {
- pos = g_explosionPos;//array
- pos.x = pos.x + (float(c * sourceRect.width) / 2 + offset * c);
- DrawTexture(g_Explosion.texture, pos, sourceRect);//array
- }
- else
- {
- if (g_PlayArea[a][b + c].IsCrate == true && ContinueExplosionPlusX == true)//array
- {
- if (g_IsBoxDestroyedXPlus == false)//array
- {
- g_PlayArea[a][b + c].IsCrate = false;
- g_IsBoxDestroyedXPlus = true;//array
- g_ValueCWhenDestrXPlus = c;//array
- }
- }
- ContinueExplosionPlusX = false;
- }
- if (g_PlayArea[a][b - c].IsPlayerTerain == true && ContinueExplosionMinX == true && g_PlayArea[a][b - c].IsCrate == false && c <= g_ValueCWhenDestrXMin)
- {
- pos = g_explosionPos;
- pos.x = pos.x - (float(c * sourceRect.width) / 2 + offset * c);
- DrawTexture(g_Explosion.texture, pos, sourceRect);
- }
- else
- {
- if (g_PlayArea[a][b - c].IsCrate == true && ContinueExplosionMinX == true)
- {
- if (g_IsBoxDestroyedXMin == false)
- {
- g_PlayArea[a][b - c].IsCrate = false;
- g_IsBoxDestroyedXMin = true;
- g_ValueCWhenDestrXMin = c;
- }
- }
- ContinueExplosionMinX = false;
- }
- if (g_PlayArea[a + c][b].IsPlayerTerain == true && ContinueExplosionPlusY == true && g_PlayArea[a+c][b].IsCrate == false && c <= g_ValueCWhenDestrYPlus)
- {
- pos = g_explosionPos;
- pos.y = pos.y + (float(c * sourceRect.height) / 2 + offset * c);
- DrawTexture(g_Explosion.texture, pos, sourceRect);
- }
- else
- {
- if (g_PlayArea[a+c][b].IsCrate == true && ContinueExplosionPlusY == true)
- {
- if (g_IsBoxDestroyedYPlus == false)
- {
- g_PlayArea[a + c][b].IsCrate = false;
- g_IsBoxDestroyedYPlus = true;
- g_ValueCWhenDestrYPlus = c;
- }
- }
- ContinueExplosionPlusY = false;
- }
- if (g_PlayArea[a - c][b].IsPlayerTerain == true && ContinueExplosionMinY == true && g_PlayArea[a - c][b].IsCrate == false && c <= g_ValueCWhenDestrYMin)
- {
- pos = g_explosionPos;
- pos.y = pos.y - (float(c * sourceRect.height) / 2 + offset * c);
- DrawTexture(g_Explosion.texture, pos, sourceRect);
- }
- else
- {
- if (g_PlayArea[a - c][b].IsCrate == true && ContinueExplosionMinY == true)
- {
- if (g_IsBoxDestroyedYMin == false)
- {
- g_PlayArea[a - c][b].IsCrate = false;
- g_IsBoxDestroyedYMin = true;
- g_ValueCWhenDestrYMin = c;
- }
- }
- ContinueExplosionMinY = false;
- }
- }
- }
- }
- }
- }
- void UpdateExplosion(float elapsedSec, int indexBomb)// make arrays for all bools/cpositions/sprites
- {
- g_Explosion.ElapsedTime += elapsedSec;
- if (g_Explosion.ElapsedTime > g_Explosion.SecondsPerFrame)
- {
- if (g_Explosion.currentFrame < g_Explosion.Maxframes)
- {
- ++g_Explosion.currentFrame;
- g_Explosion.ElapsedTime -= g_Explosion.SecondsPerFrame;
- }
- else
- {
- g_Player1Bombs[indexBomb].bombstate = Unplaced;
- g_Explosion.currentFrame = 0;
- g_IsBoxDestroyedXPlus = false;
- g_IsBoxDestroyedXMin = false;
- g_IsBoxDestroyedYPlus = false;
- g_IsBoxDestroyedYMin = false;
- g_ValueCWhenDestrXPlus = g_Player1.ExplosionSize;
- g_ValueCWhenDestrXMin = g_Player1.ExplosionSize;
- g_ValueCWhenDestrYPlus = g_Player1.ExplosionSize;
- g_ValueCWhenDestrYMin = g_Player1.ExplosionSize;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement