Hi guys.
So whenever I try to make a game I run into a problem where a circular dependency occurs between the scene or level holding my game objects and the game objects that need access to the level. I am sure this can be easily solved because my architecture is structured wrong but I just can't seem to think of an efficient solution. I'll roughly show what I have (just the parts that are causing the dependency).
Scene.h
#include "ObjectList.h"
class Scene : public EventListener
{
public:
ObjectList objectList; // This holds all the entities that are currently active in a particular scene/level.
};
ObjectList.h
#include "Entity"
class ObjectList
{
private:
std::vector<Entity*> objectList;
};
Entity.h
#include "Scene.h"
class Entity : public sf::Sprite, public EventListener
{
protected:
Scene *gameWorld;
};