Collision::2D::Entity::Grid - A container for static entities.
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);
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)
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 stuff to the grid
To install Collision::2D, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Collision::2D
CPAN shell
perl -MCPAN -e shell install Collision::2D
For more information on module installation, please visit the detailed CPAN module installation guide.