ChampDeBataille.cpp 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "ChampDeBataille.h"
  2. ChampDeBataille::ChampDeBataille(Joueur* cible,SDL_Surface* ecran,int niveauDeDifficulte):m_niveauDeDifficulte(niveauDeDifficulte),m_ecran(ecran)
  3. {
  4. for (int i(0);i<30;i++)
  5. {
  6. m_slotsHelico[i]=0;//Pour la sécurité des pointeurs
  7. }
  8. for (int i(0);i<10+optionsFire::difficulte*10;i++)
  9. {
  10. m_slotsHelico[i]= new Helico(ecran,10,i);
  11. }
  12. m_bossOne= new BossOne(ecran,cible);
  13. m_cible=cible;
  14. }
  15. ChampDeBataille::~ChampDeBataille()
  16. {
  17. for (int i(0);i<10+optionsFire::difficulte*10;i++)
  18. {
  19. delete(m_slotsHelico[i]);
  20. }
  21. delete (m_bossOne);
  22. }
  23. void ChampDeBataille::afficher()
  24. {
  25. int nbVivant(0);
  26. for (int i(0);i<10+optionsFire::difficulte*10;i++)
  27. {
  28. if (m_slotsHelico[i]->estVivant())
  29. {
  30. m_slotsHelico[i]->afficher();
  31. nbVivant++;
  32. }
  33. }
  34. if ((nbVivant!=0 )&&( !takeRand(70-2*nbVivant,SDL_GetTicks())))
  35. {
  36. m_cible->recevoirDegats(1+optionsFire::difficulte);
  37. }
  38. if (!nbVivant && m_bossOne->estVivant())
  39. {
  40. m_bossOne->afficher();
  41. }
  42. }