Hi!
I'm making a state-machine for my game.
Let's say I got a Intro-state, a Game-state, and a End-state.
They are implemented as classes, and they inherit from a abstract state class.
Like this(Psuedo code):
So you see, thease classes start up each other in a cycle.Code:
In class Intro:
-if User pressed a button:
State.nextState(new Game());
In class Game:
-if User pressed a button:
State.nextState(new End());
In class End:
-if User pressed a button:
State.nextState(new Intro());
The above works fine.
But here's the problem:
When I try to split each class into a own file, I have to include Intro in the "End" file, include "End" in the "Game" file, and include "Game" in the "Intro" file.
So when I try to compile and link this stuff, the header-files will start going bananas, cuz they link to each other in cycle.
I've tried to put the include-statements inside #ifndef SOMECLASS #define SOMECLASS #endif, stuff, but that didnt work either.
Anyone know how to deal with this?