Dragonfly 4.20
A text-based game engine
|
Public Member Functions | |
Grid () | |
~Grid () | |
void | setDimensions (int new_width, int new_height) |
int | getHeight () const |
int | getWidth () const |
int | insertObject (Object *p_o) |
int | removeObject (Object *p_o) |
Cell | positionToCell (Vector where) const |
std::set< Cell > | positionToCells (Object *p_o, Vector where) const |
ObjectList | getCollisions (Object *p_o, Vector where) const |
int | updatePosition (Object *p_o, Vector where) |
ObjectList | getObjects (Cell cell) const |
std::string | toString () const |
int | startUp () |
void | shutDown () |
void | printLog () const |
Private Attributes | |
ObjectList ** | m_p_grid |
ObjectList | m_out_of_bounds |
int | m_num_cols |
int | m_num_rows |
int | m_width |
int | m_height |
df::Grid::Grid | ( | ) |
Constructor.
df::Grid::~Grid | ( | ) |
Destructor.
ObjectList df::Grid::getCollisions | ( | Object * | p_o, |
Vector | where | ||
) | const |
Return all Objects that collide at given location.
List is empty if none.
int df::Grid::getHeight | ( | ) | const |
Get height.
ObjectList df::Grid::getObjects | ( | Cell | cell | ) | const |
Get Objects in a given Cell.
int df::Grid::getWidth | ( | ) | const |
Get width.
Cell df::Grid::positionToCell | ( | Vector | where | ) | const |
Return Cell (x,y) for given location.
Return list of Cells for given Object at given location.
Out of bounds cell is (-1, -1).
void df::Grid::printLog | ( | ) | const |
Print grid cell count to logfile.
void df::Grid::setDimensions | ( | int | new_width, |
int | new_height | ||
) |
Set dimensions. Deletes and re-creates grid.
void df::Grid::shutDown | ( | ) |
Shutdown (delete grid).
int df::Grid::startUp | ( | ) |
Startup (create grid).
Return 0 if ok, else -1.
std::string df::Grid::toString | ( | ) | const |
Return grid as string.
Move Object from old position, add to new position.
Return 0 if ok, else -1.
|
private |
Grid cell height.
|
private |
Number of columns in grid.
|
private |
Number of rows in grid.
|
private |
All out of bounds objects.
|
private |
The grid.
|
private |
Grid cell width.