Package gameobjects :: Module grid :: Class Grid
[hide private]
[frames] | no frames]

Class Grid

source code


Instance Methods [hide private]
 
__init__(self, node_factory, width, height, x_wrap=2, y_wrap=2)
Create a grid object.
source code
 
_get_x_wrap(self) source code
 
_set_x_wrap(self, x_wrap) source code
 
_get_y_wrap(self) source code
 
_set_y_wrap(self, y_wrap) source code
 
_make_wrap(self, wrap, edge) source code
 
wrap(self, coord) source code
 
wrap_x(self, x)
Wraps an x coordinate.
source code
 
wrap_y(self, y)
Wraps a y coordinate.
source code
 
get_size(self)
Retrieves the size of the grid as a tuple (width, height).
source code
 
__getitem__(self, coord) source code
 
__iter__(self) source code
 
__contains__(self, value) source code
 
clear(self)
Resets the grid.
source code
 
get(self, coord, default=None)
Retrieves a node from the grid.
source code
 
get_nodes(self, coord, size, wrap=False) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]
  x_wrap
X wrap
  y_wrap
Y wrap

Inherited from object: __class__

Method Details [hide private]

__init__(self, node_factory, width, height, x_wrap=2, y_wrap=2)
(Constructor)

source code 

Create a grid object.

node_factory -- Callable that takes the x and y coordinate of the node and returns a node object. x_wrap and y_wrap parameters should be one of (WRAP_REPEAT, WRAP_CLAMP, WRAP_ERROR).

width -- Width of the grid. height -- Height of the grid. x_wrap -- How to handle out of range x coordinates y_wrap -- How to handle out of range y coordinates
Overrides: object.__init__

wrap_x(self, x)

source code 

Wraps an x coordinate.

x -- X Coordinate

wrap_y(self, y)

source code 

Wraps a y coordinate.

y -- Y Coordinate.

get(self, coord, default=None)

source code 

Retrieves a node from the grid.

coord -- Coordinate to retrieve default -- Default value to use if coord is out of range

Property Details [hide private]

x_wrap

X wrap
Get Method:
gameobjects.grid.Grid._get_x_wrap(self)
Set Method:
gameobjects.grid.Grid._set_x_wrap(self, x_wrap)

y_wrap

Y wrap
Get Method:
gameobjects.grid.Grid._get_y_wrap(self)
Set Method:
gameobjects.grid.Grid._set_y_wrap(self, y_wrap)