-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleveldata.cpp
More file actions
60 lines (47 loc) · 1.17 KB
/
leveldata.cpp
File metadata and controls
60 lines (47 loc) · 1.17 KB
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
#include "leveldata.hpp"
using namespace std;
LevelData::LevelData(string path)
{
reloadLevelData(path);
}
void LevelData::reloadLevelData(string path)
{
// Lecture du chemin de l'image de fond
string firstLine;
ifstream file(path);
if (!file.is_open()) {
cerr << "Impossible d'ouvrir le fichier." << endl;
return;
}
getline(file, firstLine); // Lecture de la première ligne du fichier
m_terrainImagePath = firstLine;
// Lecture des données du terrain
string line;
for (int i = 0; i < ROWS; ++i) {
getline(file, line);
for (int j = 0; j < line.size(); ++j) {
m_terrainTxt[i][j] = line[j];
}
}
file.close();
}
string LevelData::getLevelPath() const
{
return m_levelPath;
}
string LevelData::getTerrainImagePath() const
{
return m_terrainImagePath;
}
void LevelData::setTerrainImagePath(string terrainImagePath)
{
m_terrainImagePath = terrainImagePath;
}
char LevelData::getTerrainTxtCase(int y, int x) const
{
return m_terrainTxt[y][x]; // TODO : ajouter une sécurité
}
int LevelData::getNextLevelCondition() const
{
return m_nextLevelCondition;
}