Class: BoundingBox

BoundingBox(centerPos, w, h) → {BoundingBox}

Defines a rectangle that is used as the border of a GameObject for collisions

Found in Chapter 6, page 297 of the textbook

Example: 6.3 Bounding Box

Constructor

new BoundingBox(centerPos, w, h) → {BoundingBox}

Parameters:
Name Type Description
centerPos vec2 center position of the bounding box in world coordinates
w float width of the bounding box
h float height of the bounding box
Source:
Returns:
a new BoundingBox instance
Type
BoundingBox

Members

(static, constant) eBoundCollideStatus

Enum for collision location
Source:

Methods

boundCollideStatus(otherBound) → {eBoundCollideStatus}

Returns the collision status of this BoundingBox with another BoundingBox
Parameters:
Name Type Description
otherBound BoundingBox the other BoundingBox to test collision with
Source:
Returns:
status - enum of collision location
Type
eBoundCollideStatus

containsPoint(x, y) → {boolean}

Tests if the world coordinate point (x,y) is within the BoundingBox
Parameters:
Name Type Description
x float horizontal world coordinate position
y float vertical world coordinate position
Source:
Returns:
if the WC point (x,y) is within the BoundingBox
Type
boolean

intersectsBound(otherBound) → {boolean}

Tests if this BoundingBox intersects the otherBound
Parameters:
Name Type Description
otherBound BoundingBox the other BoundingBox to test for intersection
Source:
Returns:
if this BoundingBox intersects the other
Type
boolean

maxX() → {float}

Returns the x world coordinate of this BoundingBox's lower right corner
Source:
Returns:
the x world coordinate of this BoundingBox's lower right corner
Type
float

maxY() → {float}

Returns the y world coordinate of this BoundingBox's upper left corner
Source:
Returns:
the y world coordinate of this BoundingBox's upper left corner
Type
float

minX() → {float}

Returns the x world coordinate of this BoundingBox's lower left corner
Source:
Returns:
the x world coordinate of this BoundingBox's lower left corner
Type
float

minY() → {float}

Returns the y world coordinate of this BoundingBox's lower left corner
Source:
Returns:
the y world coordinate of this BoundingBox's lower left corner
Type
float

setBounds(centerPos, w, h)

Sets the bounds of the BoundingBox ignoring rotation
Parameters:
Name Type Description
centerPos vec2 center position of the bounding box in world coordinates
w float width of the bounding box
h float height of the bounding box
Source: