Guest User

Untitled

a guest
Oct 30th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. #ifndef __BLOCK_H__
  2. #define __BLOCK_H__
  3.  
  4. #include <string>
  5. #include <map>
  6. #include <glm\glm.hpp>
  7. #include "globals.h"
  8.  
  9. class Block
  10. {
  11.     friend class BlockStatic;
  12.  
  13. private:
  14.     static uint32 textureID; //The gl handle to the blocks.png texture
  15.     static bool initialized; //If the texture has been loaded and ogl set up
  16.     static std::map<uint16, Block> idMap; //The map of block ids
  17.     static std::map<std::string, Block> nameMap; //The map of block names
  18.  
  19. public:
  20.     static uint32 GetTextureID(); //Returns the texture handle for the blocks.png texture
  21.     static bool IdInUse(uint16 id);
  22.     static const Block& GetBlock(uint16 id);
  23.     static bool NameInUse(std::string name);
  24.     static const Block& GetBlock(std::string name);
  25.  
  26.     //Data for blocks
  27.     static const glm::vec3 VERT_X_POS[6];
  28.     static const glm::vec3 VERT_X_NEG[6];
  29.     static const glm::vec3 VERT_Y_POS[6];
  30.     static const glm::vec3 VERT_Y_NEG[6];
  31.     static const glm::vec3 VERT_Z_POS[6];
  32.     static const glm::vec3 VERT_Z_NEG[6];
  33.     static const glm::vec3 NORM_X_POS;
  34.     static const glm::vec3 NORM_X_NEG;
  35.     static const glm::vec3 NORM_Y_POS;
  36.     static const glm::vec3 NORM_Y_NEG;
  37.     static const glm::vec3 NORM_Z_POS;
  38.     static const glm::vec3 NORM_Z_NEG;
  39.  
  40. private:
  41.     uint16 _id; //The id of the block
  42.     uint8 _tex; //The texture index (0 - 255, on the 16x16 texture atlas)
  43.     std::string _name; //The internal name of the block
  44.     bool _transparent; //If the block is transparent, DEFAULT: FALSE
  45.  
  46. protected:
  47.     void setTransparent(bool); //Sets the block transparency
  48.  
  49. public:
  50.     Block(std::string name, uint16 id, uint8 tex);
  51.  
  52.     //The non-virtual methods
  53.     uint16 GetID() const; //Returns the block id
  54.     uint8 GetIndex() const; //Returns the texture index
  55.     std::string GetName() const; //Returns the internal block name
  56.     bool IsTransparent() const; //Gets if the block is transparent
  57.  
  58. //The const instances of the blocks
  59. public:
  60.     static const Block Test;
  61. };
  62.  
  63. #endif
Advertisement
Add Comment
Please, Sign In to add comment