Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 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. // MapTile on the right blocking? - this is a call to CMap object
  49.  
  50. // Is there any entity on the right? - this is a call to EntitiesManager object
  51.  
  52. // Move player if both FALSE - move the player right
  53.  
  54. class CMapTile
  55. {
  56.  
  57. public:
  58.  
  59. enum eMapTileType
  60. {
  61. E_UNKNOWN = 0,
  62. E_FREE,
  63. E_WALL,
  64. E_ALL
  65. };
  66.  
  67. CMapTile();
  68. virtual ~CMapTile();
  69. uint8_t GetType();
  70. uint8_t IsBlocking();
  71. uint8_t GetSymbol();
  72. int GetEntityID();
  73. protected:
  74. uint8_t m_uiType;
  75. uint8_t m_uiBlocking;
  76. uint8_t m_uiSymbol;
  77. int m_iEntityID; // <<<<<<<-----
  78.  
  79. };
  80.  
  81. // Obtain tile to the right
  82. CMapTile *pTile = m_Map->GetTile(PlayerX+1,PlayerY);
  83.  
  84. // Check if blocking
  85. if(pTile->IsBlocking() == false)
  86. {
  87. // Update Player Pos to Tile position
  88. pPlayer->SetPosition(pTile->GetPosX(), pTile->GetPosY());
  89.  
  90. // Update Map Entity Id for this Tile
  91. _Tile->SetEntityId(pPlayer->GetID());
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement