collisionset

class CollisionSet(shapes: list[Shape], position: Vector = (0, 0))

An abstraction layer that allows for testing intersections between arbitrary types and numbers of shapes. Used primarily for issuing warnings when Entity objects are placed such that they overlap each other in ways that would not be permitted in game. Almost all entities use a single AABB, but this class allows for more handling more complex collisions for rail entities and others.

get_bounding_box() AABB

Gets the minimum-bounding AABB for this CollisionSet.

Returns:

An AABB with the maximal dimensions for this CollisionSet, or None if this CollisionSet has no shapes.

overlaps(other: CollisionSet) bool

Checks to see if any of this CollisionSet shapes intersect any part of other’s shapes.

Parameters:

other – The other CollisionSet to test against.

Returns:

True if they overlap, False if they do not.

rotate(amt: int) CollisionSet

Rotates all shapes within this CollisionSet by amt, where amt is in increments of 45 degrees. Contsructs a new collision set with the rotated shapes.

Parameters:

amt – The amount to rotate as multiples of 45 degrees.

Returns:

A new CollisionSet with the rotated contents.