Hi,

I have written several games in C++, but have always had difficulty to figure out how the classes should be structured. Now I'm writing a horizontal scroller game. The main character is a mage and several different spells. These spells are actually particle systems. To make the game more realistic, I have written a simple collision engine, so that my particles now collide with walls.

I chose to have a following class structure:

Code:
class GLWorld			// contains: main loop and such
							// a texture pool for loading textures (class GLTexturePool)
							// one of the members is class Level
					
class Level				// is mainly responsible for loading level description files
							// needs to have a link to the texture pool in GLWorld
								therefore the constructor takes a pointer of type GLTexturePool*
							// each level consists of several stages (class Stage)
								therefor contains vector<Stage*> Stages
						
class Stage				// responsible for loading a stage from a stage description file
							// also loads different objects
							// needs to have a link to the texture pool in GLWorld
								therefore the constructor takes a pointer of type GLTexturePool*
							// the scene is split up in several layers:
								- Background
								- Background objects
								- Solid objects
								- Front objects
						
								They are rendered in order which is indicated above.
								Therefore Stage contains vector<GLObject*> Bkg, BkgObj, SolObj, FrObj;
							// Stage holds the collision engine calculated for FrObj
							// objects can be added from outside with the void registerObject(GLObject*)
						
class GLObject			// responsible for drawing the object
							// texture ID is set by class Stage
							// holds such members as Position, Size etc
							// inherits class GameObject
					
class GameObject		// holds only a few things
								- Name
								- spesifies if this is an Enemy, Friend or Neutral object
								

class GLParticleSystem// is the class which represents particle systems
							// has a vector<GLParticle> Particles
							// needs to have a link to the texture pool in GLWorld
								therefore the constructor takes a pointer of type GLTexturePool*
							// registers each particle as an object in current Stage
								therefore needs a pointer Stage* CurrentStage to be set
Now I am planning to implement a new class, Unit. Unit will inherit GLObject. Each unit will be loaded from a description file from within Unit class. Unit will also contain vector<GLParticleSystem*> Spells. It needs to have a pointer to TexturePool in GLWorld, since it will load frames for the animation of the unit.

It is class Stage which will hold a vector<Unit*> Units.

Now my first problem is that Unit needs to have a pointer to the current Stage to be able to initialise GLParticleSystem class for the spells. That means that unit.h will include stage.h, but at the same time stage.h must include unit.h. That leads to compiler errors. How do I solve this problem?

My other question is as following: Is the structure of classes which I chose for my game good, and if not, what can you suggest I do with it?

Thanks a lot.