File tree Expand file tree Collapse file tree 6 files changed +152
-0
lines changed Expand file tree Collapse file tree 6 files changed +152
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include " GameState.h"
2
+
3
+ GameState::GameState ()
4
+ {
5
+ // ctor
6
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef GAMESTATE_H
2
+ #define GAMESTATE_H
3
+
4
+ using namespace std ;
5
+
6
+ #include < string>
7
+
8
+ class GameState // VIRTUAL class with GameState blueprint
9
+ {
10
+ public:
11
+ GameState ();
12
+
13
+ virtual void update () = 0;
14
+ virtual void render () = 0;
15
+
16
+ virtual bool onEnter () = 0; // like a load function
17
+ virtual bool onExit () = 0; // like a clena function
18
+
19
+ virtual string getStateID () const = 0;
20
+ protected:
21
+ private:
22
+ };
23
+
24
+ #endif // GAMESTATE_H
Original file line number Diff line number Diff line change
1
+ #include " MenuState.h"
2
+ #include < iostream>
3
+ using namespace std ;
4
+
5
+ const string MenuState::s_menuID = " MENU" ;
6
+
7
+ MenuState::MenuState ()
8
+ {
9
+
10
+ }
11
+
12
+ string MenuState::getStateID () const
13
+ {
14
+ return s_menuID;
15
+ }
16
+
17
+ void MenuState::update ()
18
+ {
19
+ // nothing for now
20
+ }
21
+
22
+ void MenuState::render ()
23
+ {
24
+ // nothig for now
25
+ }
26
+
27
+ bool MenuState::onEnter ()
28
+ {
29
+ cout << " entering MenuState" << endl;
30
+ return true ;
31
+ }
32
+
33
+ bool MenuState::onExit ()
34
+ {
35
+ cout << " exiting MenuState" << endl;
36
+ return true ;
37
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef MENUSTATE_H
2
+ #define MENUSTATE_H
3
+
4
+ using namespace std ;
5
+
6
+ #include < string>
7
+ #include " GameState.h"
8
+
9
+ class MenuState : public GameState
10
+ {
11
+ public:
12
+ MenuState ();
13
+
14
+ virtual void update ();
15
+ virtual void render ();
16
+
17
+ virtual bool onEnter ();
18
+ virtual bool onExit ();
19
+
20
+ virtual string getStateID () const ;
21
+ protected:
22
+ private:
23
+
24
+ static const string s_menuID;
25
+ };
26
+
27
+ #endif // MENUSTATE_H
Original file line number Diff line number Diff line change
1
+ #include " PlayState.h"
2
+ #include < iostream>
3
+
4
+ using namespace std ;
5
+
6
+ PlayState::PlayState ()
7
+ {
8
+ // ctor
9
+ }
10
+
11
+ void PlayState::update ()
12
+ {
13
+ // nothing for now
14
+ }
15
+
16
+ void PlayState::render ()
17
+ {
18
+ // nothing for now
19
+ }
20
+
21
+ bool PlayState::onEnter ()
22
+ {
23
+ cout << " entering PlayState" << endl;
24
+ return true ;
25
+ }
26
+
27
+ bool PlayState::onExit ()
28
+ {
29
+ cout << " exiting PlayState " << endl;
30
+ return true ;
31
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef PLAYSTATE_H
2
+ #define PLAYSTATE_H
3
+
4
+ using namespace std ;
5
+
6
+ #include " GameState.h"
7
+ #include < string>
8
+
9
+
10
+ class PlayState : public GameState
11
+ {
12
+ public:
13
+ PlayState ();
14
+ virtual void update ();
15
+ virtual void render ();
16
+
17
+ virtual bool onEnter ();
18
+ virtual bool onExit ();
19
+
20
+ virtual string getStateID () const ;
21
+ protected:
22
+ private:
23
+
24
+ static const string s_playID;
25
+ };
26
+
27
+ #endif // PLAYSTATE_H
You can’t perform that action at this time.
0 commit comments