Hallo!
Ich probiere gerade nur das Grundgerüst zu entwerfen für mein erstes spiel.
Ich nehme dafür die Vorlage von Galactica.
Eine Hauptklasse, die dann alles regelt.
Doch die anderen Klassen (wie zum beispiel CIntro) können nicht auf die Basisklasse zurück greifen pbwohl die instance doch extern ist (ich hoffe ich habe das richtig erklärt :lol: )
Also hier mal kurz mein test code:
main.h
|
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
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
|
#include <TriBase.h>
#include <iostream>
using namespace std;
#include "Intro.h"
#include "resource.h"
//_________________________________________________________________________
// Spielstände
//_________________________________________________________________________
enum EGameState
{
GS_NONE, // Kein Spielzustand
GS_INTRO, // Intro
GS_MAIN_MENU, // Hauptmenü
GS_GAME // Spiel
};
//_________________________________________________________________________
// -----------------------
//_________________________________________________________________________
//_________________________________________________________________________
// Hauptklasse
//_________________________________________________________________________
class CSpaceStrike
{
public: CIntro* Intro;
int GS; //GameState id
public: tbResult Load(); //Laden
tbResult Move(float fTime); //Bewegen
tbResult Render(float fTime); //Zeichnen
tbResult Unload(); //Löschen
};
//_________________________________________________________________________
// -----------------------
//_________________________________________________________________________
//_________________________________________________________________________
// Globale Variable
//_________________________________________________________________________
extern CSpaceStrike* g_pSpaceStrike;
//_________________________________________________________________________
// -----------------------
//_________________________________________________________________________
|
main.cpp
|
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
|
#include "main.h"
tbResult CSpaceStrike::Load()
{
GS=GS_NONE;
Intro = new CIntro;
Intro->Load();
return TB_OK;
}
tbResult CSpaceStrike::Move(float fTime)
{
return TB_OK;
}
tbResult CSpaceStrike::Render(float fTime)
{
return TB_OK;
}
tbResult CSpaceStrike::Unload()
{
return TB_OK;
}
int main()
{
return 0;
}
|
intro.h
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
|
class CIntro
{
public: tbResult Load(); //Laden
tbResult Move(float fTime); //Bewegen
tbResult Render(float fTime); //Zeichnen
tbResult Unload(); //Löschen
};
|
intro.cpp
|
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
|
#include "main.h"
tbResult CIntro::Load()
{
g_pSpaceStrike = new CSpaceStrike;
cout << g_pSpaceStrike->GS << endl;
return TB_OK;
}
tbResult CIntro::Move(float fTime)
{
return TB_OK;
}
tbResult CIntro::Render(float fTime)
{
return TB_OK;
}
tbResult CIntro::Unload()
{
return TB_OK;
}
|
Was mache ich falsch?
Gruß flo
ps: wahrscheinlich wieder so ein banahler fehler!