Collision::2D::Collision - An object representing a collision betwixt 2 entities
The time of collision. For example, consider a point-circle collision, where the point is moving towards the circle. $collision->time is the exact moment of collision between the two.
The axis of collision. Basically a vector from one entity to the other. It depends entirely on how they collide.
If the collision involves a vertical or horizontal line, the axis will be 'x' or 'y'. If it's between a point or corner and a circle, it will be an arrayref, of the form [$x,$y].
This vector will not be normal (normal means of length 1). Collision::2D::normalize_vec($v) is provided for that purpose.
Again, the axis of collision. If you call this, it will always return the vector form [$x,$y]. If the axis existed as 'x' or 'y', it is translated to [$x,$y].
$collision->ent1
This is to provide some context for "axis". This is useful because dynamic_collision doesn't preserve the order of your entities. If you would like for the order to be preserved, use the entity->collide($ent2) method, or use the keep_order parameter in dynamic_collision.
entity->collide($ent2)
dynamic_collision
my $bouncevec = $co->bounce_vector (elasticity => .8);
Assuming that $co->ent2 has infinite mass, the $co->bounce_vector is the resulting velocity of $co->ent1. The elasticity parameter is 1 by default.
$co->ent2
$co->bounce_vector
$co->ent1
my $other_collision = $self->invert();
This returns the inverse of this collision. That is, the time remains, but ent1 and ent2 are swapped, and the axis is inversed. This does not effect $self.
1 POD Error
The following errors were encountered while parsing the POD:
=over without closing =back
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.