Started to write my own RL, and already fell into analysis (paralysis?) when implementing map class.


My **TILE** class looks like:

    class CMapTile
    {
      
    public:
        
        enum eMapTileType
        {
            E_UNKNOWN = 0,
            E_FREE,
            E_WALL,
            E_ALL
        };
        
        CMapTile();
        virtual ~CMapTile();
        uint8_t GetType();
        uint8_t IsBlocking();
        uint8_t GetSymbol();
        
    protected:
        uint8_t m_uiType;
        uint8_t m_uiBlocking;
        uint8_t m_uiSymbol;
        
        
    };


Then i wrote a class for the map itself



    #include "CMapTile.hpp"
    
    class CMap
    {
    public:
        
        CMap();
        void Init(const uint8_t& ruiWidth, const uint8_t&  ruiHeight);
        void Generate();
        void Print();
        CMapTile GetTile(const uint8_t& ruiX, const uint8_t& ruiY) const;
        
    private:
        
        uint8_t m_uiWidth;
        uint8_t m_uiHeight;
        
        std::vector<CMapTile> m_vTiles; 
    };

And here is me thinking. With the design above, Map has no idea about entities. Entities have no idea about map.

So when i want to move Player **RIGHT** given above i will have to make two checks (totally separated). A check for map if tile is blocking and a check in a vector of entities if there is any entity on that position (X+1).

    // MapTile on the right blocking? - this is a call to CMap object
    
    // Is there any entity on the right? - this is a call to EntitiesManager object
    
    // Move player if both FALSE - move the player right


Maybe instead i should have an integer in the CMapTile storing an id of an entity, like below:

    class CMapTile
    {
      
    public:
        
        enum eMapTileType
        {
            E_UNKNOWN = 0,
            E_FREE,
            E_WALL,
            E_ALL
        };
        
        CMapTile();
        virtual ~CMapTile();
        uint8_t GetType();
        uint8_t IsBlocking();
        uint8_t GetSymbol();
        int     GetEntityID();
    protected:
        uint8_t m_uiType;
        uint8_t m_uiBlocking;
        uint8_t m_uiSymbol;
        int     m_iEntityID; // <<<<<<<-----
        
    };

Thanks to which i can make a simple call to CMap like this to check if i can move player Right:



    // Obtain tile to the right
    CMapTile *pTile = m_Map->GetTile(PlayerX+1,PlayerY);
    
    // Check if blocking
    if(pTile->IsBlocking() == false)
    {
        // Update Player Pos to Tile position
        pPlayer->SetPosition(pTile->GetPosX(), pTile->GetPosY());
        
        // Update Map Entity Id for this Tile
        _Tile->SetEntityId(pPlayer->GetID());
    }



With the above CMapTile::IsBlocking would have to know about Entity class, to figure out if entity is a blocking type or not.


The same question applies for rendering,
When rendering. With the initial design i would have to

1. Render the map first
2. Render entities next

instead of

1. Render the map + entities in one (for... loop)

What's your opinion / suggestion - any pitfalls you see that can show up later?