//---------------------------------------------------------------------------
// All the shit for the explosions
//---------------------------------------------------------------------------

Character *Explosions[8];
int NbrExplosion;

//-------------------------------------
// Load the explosions animation
//-------------------------------------
int LoadExplosions (u_long *memptr)
{
   int i;

   *memptr = (*memptr + 3) & 0xFFFFFFFC;
   Explosions[0] = (Character *)*memptr;
   *memptr += sizeof (Character);

   if (LE1orLE2 == 0)
      Explosions[0]->Load ("\\SPRITES\\EXPLO.KRT", memptr);
   else
      Explosions[0]->Load ("\\SPRITES\\LE2\\EXPLO.KRT", memptr);

   for (i = 1; i < 8; i++)
   {
      Explosions[i] = Explosions[0]->Clone_Character (0, memptr);
   }
}

//-------------------------------------
// Start a new explosion animation
//-------------------------------------
void NewExplosion (int coorx, int coory, int depth, int scal)
{
   int i = NbrExplosion;
   signed char ExploSnd[6] = {-1,21,15,6,8,0};
   NbrExplosion = (NbrExplosion + 1) & 7;

   Explosions[i]->Set_Location (coorx, coory);
   Explosions[i]->Scale (scal);
   if ((ActualScript == 17) && (LE1orLE2 == 0))
      Explosions[i]->SetDepth (depth);
   else if ((ActualScript == 7) && (LE1orLE2 == 1))
      Explosions[i]->SetDepth (depth);
   else if (depth < 11)
      Explosions[i]->SetDepth (11);
   else
      Explosions[i]->SetDepth (depth);
   Explosions[i]->StartAction (0, 0);

   if (LE1orLE2 == 0)
   {
      if (ExploSnd[LevelSelected] != -1)
         PlaySFX (bkdvab, ExploSnd[LevelSelected], 127,127);
   }
}

//-------------------------------------
// Display those innocent victim
// sprites
//-------------------------------------
inline void DrawExplosions (int bkdx, int bkdy, DoubleBuffer *db)
{
   int Sfx, Vab, dummy, i;

   shootpnt *spoi;

   for (i = 0; i < 8; i++)
      Explosions[i]->DrawNextFrame (bkdx, bkdy, db, &Sfx, &Vab, &dummy);
}
