hi sorry das ich wieder nerven muss
aber ich hab mal wieder ein problem.
habe das mit dem laden jetzt eigetnlich hin bekommen :
|
C-/C++-Quelltext
|
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
|
void tilemap :: load(std::string Map)
{
ifstream LoadM;
LoadM.open(Map + ".lvl");
for(int i = 0;i < 32;i++)
{
getline(LoadM,name);
for(int j = 0;j<name.length();j++)
{
if(name.c_str()[j]!=',')
tile[i][j] = name.c_str()[j];
cout << tile[i][j];
}
}
LoadM.close();
}
|
aber jetzt muss ihrgendein fehler in meiner draw funktion sein, denn die y achse wird immer nur alle 2 felder gezeichnet
|
C-/C++-Quelltext
|
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
|
void tilemap ::draw(sf::RenderWindow &Window)
{
sf::Image FenceI;
if(!FenceI.LoadFromFile("data/image/fence.png"))
{}
sf::Sprite Fence(FenceI);
sf::Image bottomI;
if(!bottomI.LoadFromFile("data/image/bottom.png"))
{}
sf::Sprite bottom(bottomI);
sf::Image EarthI;
if(!EarthI.LoadFromFile("data/image/earth.png"))
{}
sf::Sprite Earth(EarthI);
const unsigned int m_hoehe = 32;
const unsigned int m_breite = 32;
const unsigned int t_hoehe = 32;
const unsigned int t_breite = 32;
for(int i = 0; i < m_hoehe;i++)
{
for(int j = 0;j < m_breite;j++)
{
bottom.SetPosition(i*t_hoehe,j*t_breite);
Window.Draw(bottom);
switch(tile[i][j])
{
case '0':
Fence.SetPosition(i*t_hoehe,j*t_breite);
Window.Draw(Fence);
break;
case '2':
Earth.SetPosition(i*t_hoehe,j*t_breite);
Window.Draw(Earth);
default:
break;
}
}
}
Window.Display();
}
|
hab mal ein bild als anhang