|
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
50
51
52
53
54
|
void CGame::followPath()
{
ElapsedTime = g_pTimer->Get_Elapsed();
if (Walkstat == 0)
{
if(ClosedList.front().x == static_cast<int>(Enemy.pSprite->GetPosition().x/32) +1)
{
Walkstat = 1;
}
else if(ClosedList.front().x == static_cast<int>(Enemy.pSprite->GetPosition().x/32) -1)
{
Walkstat = 2;
}
else if(ClosedList.front().y == static_cast<int>(Enemy.pSprite->GetPosition().y/32) +1)
{
Walkstat = 3;
}
else if(ClosedList.front().y == static_cast<int>(Enemy.pSprite->GetPosition().y/32) -1)
{
Walkstat = 4;
}
}else if(Walkstat == 1)
{
Enemy.pSprite->Move(50*ElapsedTime,0);
}
else if(Walkstat == 2)
{
Enemy.pSprite->Move(-50*ElapsedTime,0);
}
else if(Walkstat == 3)
{
Enemy.pSprite->Move(0,50*ElapsedTime);
}
else if(Walkstat == 4)
{
Enemy.pSprite->Move(0,-50*ElapsedTime);
}
if(ClosedList.front().x == static_cast<int>(Enemy.pSprite->GetPosition().x/32)
&& ClosedList.front().y == static_cast<int>(Enemy.pSprite->GetPosition().y/32))
{
ClosedList.pop_front();
Walkstst = 0;
}
}
|
Ok , soweit klappt es. *atmet erleichtert und gleichzeitig erschöpft aus*
Das Prüfen ob die Liste leer ist usw. ist noch nicht dabei, wird aber gerade hinzugefügt.
@Architekt:
Danke für die Links, ich hab den Stack nicht ganz verstanden.
Ehrlich gesagt kapier ich erst jetzt, dass damit etwas anderes gemeint ist als der "interne" Stack. (Thema: Speicherverwaltung)
Ich versteh noch nicht so ganz wie ich ihn in diesem Fall verwenden und implementieren sollte aber ich werde versuchen mich etwas in dieses Thema zu vertiefen.
MfG Dastan