Path: /sdk/add_on/scriptgrid/
The grid
type is a template object that allow the scripts to declare 2D grids of any type. In many ways it is similar to the array template object, but it is specialized for use with areas.
The type is registered with RegisterScriptGrid(asIScriptEngine *engine)
.
class grid<T> { grid(); grid(uint width, uint height); grid(uint width, uint height, const T &in fillValue); uint width() const; uint height() const; void resize(uint w, uint h); T &opIndex(uint x, uint y); const T &opIndex(uint x, uint y) const; }
grid()
grid(uint width, uint height)
grid(uint width, height, const T &in fillValue)
The constructors initializes the grid object. The default constructor will create an zero sized grid.
uint width() const
uint height() const
Returns the width and height of the grid.
void resize(uint w, uint h)
Resizes the grid to the new dimension. The elements that still fit in the grid will keep their values.
T &opIndex(uint x, uint y)
const T &opIndex(uint x, uint y) const
The index operator returns a reference to one of the elements. If the index is out of bounds a script exception will be raised.
// Initialize a 5x5 map grid<int> map = {{1,0,1,1,1}, {0,0,1,0,0}, {0,1,1,0,1}, {0,1,1,0,1}, {0,0,0,0,1}}; // A function to verify if the next area is walkable bool canWalk(uint x, uint y) { // If the map in the destination is // clear, it is possible to wark there return map[x,y] == 0; }