Collision::2D::Entity - A moving entity. Don't use this directly.
Absolute position and velocity in space. These are necessary if you want to do collisions through dynamic_collision
You shouldn't worry about these. Move along now.
Relative position and velocity in space. these are necessary if you want to do collisions directly through entity methods,
In this case, both the absolute and relative position and velocity of $circ2 is not used. The relative attributes of $circ1 are assumed to be relative to $circ2.
my $collision = $self->collide ($other_entity, interval=>4);
Detect collision with another entity. $self must be normalized to $other. Takes interval as a parameter. Returns a collision if there is a collision. Returns undef if there is no collision.
With the collide method, the entity order is preserved. Consider this example:
my $collision1 = $panel->collide($droplet);
my $collision2 = $droplet->collide($panel);
If these objects collide, then its $collision1-ent1> will be $panel, and $collision2-ent1> will be $droplet.
my $t_or_f = $self->intersect ($other_entity, interval=>2.5);
Detect intersection (overlapping) with another entity. Takes interval as a parameter. Returns a collision if there is a collision. Returns undef if there is no collision.
interval is optional. interval is 1 by default.
Relative vectors and velocity are not considered for intersection.
You probably shouldn't use this directly. At all. Relative vectors are handled automatically in dynamic_collision and in $ent1-collide($ent2)>
$self->normalize($other); # $other isa entity
This compares the absolute attributes of $self and $other. It only sets the relative attributes of $self. This is necessary to call _collide_*($other) methods on $self.
To install Collision::2D, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.