Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.
Kayne Ruse edited this page Dec 15, 2016 · 2 revisions

Introduction

Region objects hold a number of tiles, equal to REGION_WIDTH * REGION_HEIGHT. Each tile has a number of layers equal to REGION_DEPTH, as well as a flag indicating if that tile is solid or not. Regions are handled and processed by RegionPagerBase (and RegionPagerLua), and generally don't exist on their own.

Globals

//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

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

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).

Please note that the default constructor is explicitly deleted.

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.

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.

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.

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.

int GetX() const;

This returns the x value of the Region. It is guaranteed to be a multiple of REGION_WIDTH.

int GetY() const;

This returns the y value of the Region. It is guaranteed to be a multiple of REGION_HEIGHT.

std::bitset<REGION_WIDTH*REGION_HEIGHT>* 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.

Clone this wiki locally