NAME

Collision::2D::Entity::Rect - A rectangle entity.

DESCRIPTION

This is an entity with height and width. Attributes (x, y) is one corner of the rect, whereas (x+w,y+h) is the opposite corner.

ATTRIBUTES

w, h

Width and height of the rectangle.

METHODS

Anything in Collision::2D::Entity.

collide

See Collision::2D::Entity->collide

print 'boom' if $rect->collide($rect);
print 'zing' if $rect->collide($circle);
print 'yotz' if $rect->collide($grid);

intersect

See Collision::2D::Entity->intersect

print 'bam' if $rect->intersect($rect);
# etc..