1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| bool LoadFile(string filename,int X,int Y,vector<int> &dataTable)
{
string pathfile = "MapFile/" + filename;
ifstream fichier;
fichier.open(pathfile,ios::beg);
if (fichier.is_open())
{
int nbVal = X*Y;
for (int i = 0; i < nbVal; i++)
{
vector<int> tableau;
int valeur;
fichier >> valeur;
dataTable.push_back(valeur);
}
}
else
{
return false;
}
fichier.close();
return true;
}
int GetInformation(dataMap &mapData)
{
string dataTexture1File;
string dataTexture2File;
string dataCollisionFile;
string dataEventFile;
int m_mapX;
int m_mapY;
vector<int> m_dataTexture1;
vector<int> m_dataTexture2;
vector<int> m_dataCollision;
vector<int> m_dataEvent;
cout << "Largeur de la map: ";
cin >> m_mapX;
cout << endl;
if (m_mapX <= 0) return 1;
cout << "Hauteur de la map: ";
cin >> m_mapY;
cout << endl;
if (m_mapY <= 0) return 1;
//CHARGEMENT TEXTURE INFERIEUR//
cout << "Fichier de la texture inferieur: ";
cin >> dataTexture1File;
cout << endl << "Chargement du fichier ..." << endl;
if (LoadFile(dataTexture1File, m_mapX, m_mapY, m_dataTexture1))
{
cout << "Chargement du fichier reussi !" << endl << endl;
}
else
{
return 2;
}
//CHARGEMENT TEXTURE SUPERIEUR//
cout << "Fichier de la texture superieur: ";
cin >> dataTexture2File;
cout << endl << "Chargement du fichier ..." << endl;
if (LoadFile(dataTexture2File, m_mapX, m_mapY, m_dataTexture2))
{
cout << "Chargement du fichier reussi !" << endl << endl;
}
else
{
return 2;
}
//CHARGEMENT COLLISION//
cout << "Fichier de collision: ";
cin >> dataCollisionFile;
cout << endl << "Chargement du fichier ..." << endl;
if (LoadFile(dataCollisionFile, m_mapX, m_mapY, m_dataCollision))
{
cout << "Chargement du fichier reussi !" << endl << endl;
}
else
{
return 2;
}
//CHARGEMENT EVENT//
cout << "Fichier des evenements: ";
cin >> dataEventFile;
cout << endl << "Chargement du fichier ..." << endl;
if (LoadFile(dataEventFile, m_mapX, m_mapY, m_dataEvent))
{
cout << "Chargement du fichier reussi !" << endl << endl;
}
else
{
return 2;
}
cout << "----------------------------------------------------" << endl;
cout << "TEXTURE INFERIEUR: " << dataTexture1File << endl;
cout << "TEXTURE SUPERIEUR: " << dataTexture2File << endl;
cout << "COLLISION: " << dataCollisionFile << endl;
cout << "EVENEMENT: " << dataEventFile << endl;
cout << "----------------------------------------------------" << endl << endl;
return 0;
} |
Partager