Hey.
Ich hab angefangen mir ein kleinees Spiel zu programmieren und wollte die Funktion schreiben,die das Labyrinth erzeugt.
Um zu testen ob die Funktion auch wirklich funst hab ich die"halbfertige" Funktion einfach mal getestet.
(
|
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
|
void CGame::GenerateLab()
{for(int i = 0;i<17;i++)
{
m_iCellValues[i][0] = -1;
}
for(int i = 0;i<19;i++)
{
m_iCellValues[0][i] = -1;
m_iCellValues[16][i]= -1;
}
cout<<"Setting walls..."<<endl;
for(int i = 0;i<17;i++)
{ for(int j = 0;i<19;j++)
{
if(m_iCellValues[i][j] == -1)
{
m_pCell = new CCell();
m_pCell->SetWall((i*50),(j*50));
cout<<"Setting wall done..."<<endl;
m_lCells.push_back(m_pCell);
cout<<"pushed wall to list..."<<endl;
}
}
}
cout<<"Setting walls Done..."<<endl;
}
//Die nötigen Variablen & andere Funktionen...
//aus der CGame Klasse:
int m_iCellValues[17][19];
list<CCell*> m_lCells;
list<CCell*>::iterator i;
//Aus der Klasse CCell(soll die Informationen einer Zelle speichern)
void CCell::SetWall(int xCor,int yCor)
{
m_fXPos = static_cast<float> (xCor);
m_fYPos = static_cast<float> (yCor);
m_pWallSprite = new CSprite;
m_pWallSprite->Load("Img/wall.bmp");
m_pWallSprite->SetPos(m_fXPos,m_fYPos);
m_iCellValue = -1;
}
|
So...Wenn ich dann das Programm starte hängt es sich irgendwann in der for-schleife(z.12 denke ich mal...)auf und stürzt ab...
1)Warum kann das sein?Irgendwas mit zuviel Speicher verbraucht oder...?Ich komm da einfach nicht drauf.Das Buch liefert auch keine näheren Informationen ...
Wenns ein eher simpler Fehler ist würde mir auch ein Tipp in die richtige Richtung reichen
2)Wenn das einfacher gehen würde,wäre ich dankbar,wenn das jemand sagen könnte (:
lg