Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. class CMapTile
  2. {
  3.  
  4. public:
  5.  
  6. enum eMapTileType
  7. {
  8. E_UNKNOWN = 0,
  9. E_FREE,
  10. E_WALL,
  11. E_ALL
  12. };
  13.  
  14. CMapTile();
  15. virtual ~CMapTile();
  16. uint8_t GetType();
  17. uint8_t IsBlocking();
  18. uint8_t GetSymbol();
  19.  
  20. protected:
  21. uint8_t m_uiType;
  22. uint8_t m_uiBlocking;
  23. uint8_t m_uiSymbol;
  24.  
  25.  
  26. };
  27.  
  28. #include "CMapTile.hpp"
  29.  
  30. class CMap
  31. {
  32. public:
  33.  
  34. CMap();
  35. void Init(const uint8_t& ruiWidth, const uint8_t& ruiHeight);
  36. void Generate();
  37. void Print();
  38. CMapTile GetTile(const uint8_t& ruiX, const uint8_t& ruiY) const;
  39.  
  40. private:
  41.  
  42. uint8_t m_uiWidth;
  43. uint8_t m_uiHeight;
  44.  
  45. std::vector<CMapTile> m_vTiles;
  46. };
  47.  
  48. // Obtain tile to the right
  49. CMapTile *pTile = m_Map->GetTile(pPlayer->GetPosX()+1, pPlayer->GetPosY());
  50.  
  51. // Obtain entity to the right
  52. CEntity *pEntityToRight = m_EntitiesManager.GetEntity(pPlayer->GetPosX()+1, pPlayer->GetPosY());
  53.  
  54. // Check if blocking
  55. if(pTile != NULL && pTile->IsBlocking() == false)
  56. {
  57.  
  58. // Check if any entity there and blocking
  59. if(pEntityToRight != NULL && pEntityToRight->IsBlocking == false)
  60. {
  61. // Update Player Pos to Tile position
  62. pPlayer->SetPosition(pTile->GetPosX(), pTile->GetPosY());
  63.  
  64. // Update Map Entity Id for this Tile
  65. _Tile->SetEntityId(pPlayer->GetID());
  66. }
  67. }
  68.  
  69. class CMapTile
  70. {
  71.  
  72. public:
  73.  
  74. enum eMapTileType
  75. {
  76. E_UNKNOWN = 0,
  77. E_FREE,
  78. E_WALL,
  79. E_ALL
  80. };
  81.  
  82. CMapTile();
  83. virtual ~CMapTile();
  84. uint8_t GetType();
  85. uint8_t IsBlocking();
  86. uint8_t GetSymbol();
  87. int GetEntityID();
  88. protected:
  89. uint8_t m_uiType;
  90. uint8_t m_uiBlocking;
  91. uint8_t m_uiSymbol;
  92. int m_iEntityID; // <<<<<<<-----
  93.  
  94. };
  95.  
  96. // Obtain tile to the right
  97. CMapTile *pTile = m_Map->GetTile(pPlayer->GetPosX()+1, pPlayer->GetPosY());
  98.  
  99. // Check if blocking
  100. if(pTile->IsBlocking() == false)
  101. {
  102. // Update Player Pos to Tile position
  103. pPlayer->SetPosition(pTile->GetPosX(), pTile->GetPosY());
  104.  
  105. // Update Map Entity Id for this Tile
  106. _Tile->SetEntityId(pPlayer->GetID());
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement