diff --git a/Home.md b/Home.md index 2741668..849e7d6 100644 --- a/Home.md +++ b/Home.md @@ -12,8 +12,7 @@ This is a straight forward way of learning how to use TurtleMap. This is a breakdown of each class, it's methods and it's APIs, for quick lookup. -* Global Variables And Their Uses -* Region +* [Region](region) * Region API * Region Pager Base * Region Pager Lua diff --git a/region.md b/region.md new file mode 100644 index 0000000..d6e4407 --- /dev/null +++ b/region.md @@ -0,0 +1,71 @@ +# Globals + +```C++ +//the region's storage format +constexpr int REGION_WIDTH = 20; +constexpr int REGION_HEIGHT = 20; +constexpr int REGION_DEPTH = 3; +``` + +These define the size of Region's storage area. The defaults given are the only values officially supported, but these should be flexible enough to support any value above zero if needed. + +# Public Data Types + +```C++ +typedef unsigned char type_t; +``` + +This is the datatype of a single tile. This is defined so it can be altered, in the event that larger tile sheets are needed. The default only supports up to 255 different tile values, in order to save memory. Please note that altering this will drastically change the size of Region. + +# Methods + +```C++ +Region(int x, int y); +Region(Region const&); +``` + +This is Region's constructor. The first version takes an `x` & `y` value as a parameter, while the second version, the copy constructor, takes another `Region` as a parameter. Please note that the parameters `x` & `y` must be multiples of `REGION_WIDTH` and `REGION_HEIGHT` respectfully, otherwise an exception is thrown (multiples can be zero, or negatives). + +```C++ +type_t SetTile(int x, int y, int z, type_t v); +``` + +This takes an `x`, `y`, and `z` zero indexed parameter, indicating a tile in the region, and a layer. `v` is the new value for that tile. If `x`, `y` or `z` are out of bounds, an exception is thrown. + +```C++ +type_t GetTile(int x, int y, int z) const; +``` + +This takes an `x`, `y`, and `z` zero indexed parameter, indicating a tile in the region, and a layer. It will return that tile_t. If `x`, `y` or `z` are out of bounds, an exception is thrown. + +```C++ +bool SetSolid(int x, int y, bool b); +``` + +This takes an `x` and `y` parameter, indicating a tile in the region. `b` indicates whether it should be solid (true) or not (false). If `x` or `y` are out of bounds, an exception is thrown. + +```C++ +bool GetSolid(int x, int y) const; +``` + +This takes an `x` and `y` parameter, indicating a tile in the region. It returns whether it's solid (true) or not (false). If `x` or `y` are out of bounds, an exception is thrown. + +```C++ +int GetX() const; +``` + +This returns the `x` value of the Region. It is guaranteed to be a multiple of REGION_WIDTH. + +```C++ +int GetY() const; +``` + +This returns the `y` value of the Region. It is guaranteed to be a multiple of REGION_HEIGHT. + +```C++ +std::bitset* GetSolidBitset(); +``` + +This is an OO-breaking utility function, allowing access to the internal state of the boolean array representng the solidity of the tiles. + +This method is not officially supported.