| Home | Trees | Index | Help |
|---|
|
|
A container class that organizes objects by their location, based on
an attribute whose value is a pygame rect. Each
ProximityGrid divides the world into a grid of fixed-sized
tiles, and records
which tiles each contained object's rect attribute
intersects with.
In order to keep the proximity grid up-to-date, it's
update method must be called on an object whenever that
object's rect-valued attribute is modified.
ProximityGrids are useful because they let us quickly
look up all objects that are close to a given point or rect.
For more details, see the documentation for the near_point() and near_rect() methods.
| Method Summary | |
|---|---|
Create a new, empty, ProximityGrid. | |
Return a list of all objects in the ProximityGrid | |
Add a new object to the ProximityGrid. | |
near_point(self,
x,
y)
| |
near_rect(self,
rect)
| |
Remove an object from the ProximityGrid. | |
update(self,
object)
| |
| Method Details |
|---|
__init__(self,
tile_width,
tile_height,
rect_attr='rect')
Create a new, empty, |
__iter__(self)Return a list of all objects in theProximityGrid
|
add(self, object)Add a new object to theProximityGrid.
object must define the rect-valued attribute
specified in the ProximityGrid constructor to be a pygame
rect.
|
near_point(self, x, y) |
near_rect(self, rect) |
remove(self, object)Remove an object from theProximityGrid.
|
update(self, object) |
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Thu Sep 22 22:52:47 2005 | http://epydoc.sf.net |