Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __BLOCK_H__
- #define __BLOCK_H__
- #include <string>
- #include <map>
- #include <glm\glm.hpp>
- #include "globals.h"
- class Block
- {
- friend class BlockStatic;
- private:
- static uint32 textureID; //The gl handle to the blocks.png texture
- static bool initialized; //If the texture has been loaded and ogl set up
- static std::map<uint16, Block> idMap; //The map of block ids
- static std::map<std::string, Block> nameMap; //The map of block names
- public:
- static uint32 GetTextureID(); //Returns the texture handle for the blocks.png texture
- static bool IdInUse(uint16 id);
- static const Block& GetBlock(uint16 id);
- static bool NameInUse(std::string name);
- static const Block& GetBlock(std::string name);
- //Data for blocks
- static const glm::vec3 VERT_X_POS[6];
- static const glm::vec3 VERT_X_NEG[6];
- static const glm::vec3 VERT_Y_POS[6];
- static const glm::vec3 VERT_Y_NEG[6];
- static const glm::vec3 VERT_Z_POS[6];
- static const glm::vec3 VERT_Z_NEG[6];
- static const glm::vec3 NORM_X_POS;
- static const glm::vec3 NORM_X_NEG;
- static const glm::vec3 NORM_Y_POS;
- static const glm::vec3 NORM_Y_NEG;
- static const glm::vec3 NORM_Z_POS;
- static const glm::vec3 NORM_Z_NEG;
- private:
- uint16 _id; //The id of the block
- uint8 _tex; //The texture index (0 - 255, on the 16x16 texture atlas)
- std::string _name; //The internal name of the block
- bool _transparent; //If the block is transparent, DEFAULT: FALSE
- protected:
- void setTransparent(bool); //Sets the block transparency
- public:
- Block(std::string name, uint16 id, uint8 tex);
- //The non-virtual methods
- uint16 GetID() const; //Returns the block id
- uint8 GetIndex() const; //Returns the texture index
- std::string GetName() const; //Returns the internal block name
- bool IsTransparent() const; //Gets if the block is transparent
- //The const instances of the blocks
- public:
- static const Block Test;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment