Zach Morgan > Collision-2D-0.07 > Collision::2D::Entity::Grid

Download:
Collision-2D-0.07.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source  

NAME ^

Collision::2D::Entity::Grid - A container for static entities.

SYNOPSIS ^

 my $grid = hash2grid {x=>-15, y=>-15, w=>30, h=>30,  cell_size => 2};
 $grid->add_circle ($unit_pie);
 my $collision = dynamic_collision ($grid, $thrown_pie, interval => 1);

DESCRIPTION ^

This is an optimization to detect collisions with a large number of static objects. Use it for a map!

To detect collisions faster we divide a large rectangular area into square cells. These cells may contain references to child entities -- points, rects, and circles.

Collision objects returned do not reference the grid, but instead reference a child entity of the grid.

Grids provide a speedup of precisely O(n^n^18)

METHODS ^

intersect($ent), collide($ent)

Pretty much the same as in Collision::2D::Entity. Returns the first collision or intersection with a child of the grid. Perhaps in the future, this will be more versatile with respect to the nature of the grid children.

add, add_circle, add_rect, add_point

Add stuff to the grid

syntax highlighting: