Starter.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "Starter.h"
  2. Starter::Starter( int xSize, int ySize ): m_xSize( xSize ), m_ySize( ySize ) //TODO m_xl(0x0),
  3. {
  4. }
  5. Starter::~Starter()
  6. {
  7. //dtor
  8. }
  9. void Starter::loadAreas()
  10. {
  11. /// Config
  12. std::string const source("Spawns/spawn1.txt");
  13. std::ifstream fluxIn(source.c_str());
  14. int x, y, d;
  15. /// Attributions
  16. if (fluxIn)
  17. {
  18. //Ouverture fichier succés
  19. for (int i(0); i<12; i++)
  20. {
  21. fluxIn >> x ;
  22. fluxIn >> y ;
  23. fluxIn >> d ;
  24. if ( x < 0 )
  25. x += m_xSize;
  26. if ( y < 0 )
  27. y += m_ySize;
  28. m_xl.push_back(x);
  29. m_yl.push_back(y);
  30. m_dl.push_back(d);
  31. }
  32. }
  33. else
  34. {
  35. //Echec ouverture fichier
  36. std::cout << "ERREUR: impossible de lire le fichier " << source << " ." << std::endl;
  37. /// Spawn à la main
  38. // 1
  39. m_xl.push_back(5);
  40. m_yl.push_back(5);
  41. m_dl.push_back(BAS);
  42. // 1
  43. m_xl.push_back(10);
  44. m_yl.push_back(5);
  45. m_dl.push_back(DROITE);
  46. // 1
  47. m_xl.push_back(5);
  48. m_yl.push_back(4);
  49. m_dl.push_back(HAUT);
  50. // 1
  51. m_xl.push_back(5);
  52. m_yl.push_back(10);
  53. m_dl.push_back(DROITE);
  54. // 1
  55. m_xl.push_back(5);
  56. m_yl.push_back(15);
  57. m_dl.push_back(DROITE);
  58. }
  59. std::cout << "m_xl.size() " << m_xl.size() << std::endl ;
  60. std::cout << "m_yl.size() " << m_yl.size() << std::endl ;
  61. std::cout << "m_dl.size() " << m_dl.size() << std::endl ;
  62. }
  63. void Starter::spawnLiners( Liner** linerTab, int nbJoueurs )
  64. {
  65. for ( unsigned int i(0); i < nbJoueurs; i ++ )
  66. {
  67. linerTab[i]->reset( m_xl[i], m_yl[i], m_dl[i] );
  68. }
  69. }