FangEngine.game_object.hitbox

This module contains the hitbox object

Class Hitbox

Represents a rectangular hitbox of an object

__init__(self, x: float, y: float, w: float, h: float)

Parameter x:
Parameter y:
Parameter w:
Parameter h:

__repr__(self)

area(self) -> float

Returns the area of the hitbox

bottom_left(self) -> typing.Tuple[float, float]

Returns the bottom left position of the hitbox

bottom_right(self) -> typing.Tuple[float, float]

Returns the bottom right position of the hitbox

diagonal(self)

Returns the diagonal length of the hitbox

draw_hitbox(self, buffer: Surface, color: typing.Tuple[int, int, int] = (255, 255, 255), width: int = 2)

Draws the hitbox to the specified buffer
Parameter buffer:
Parameter color:
Parameter width: the line width to draw the hitbox (use 0 to fill)

is_hitbox_colliding(self, hitbox: Hitbox) -> bool

Determines if the specified hitbox is colliding with the hitbox

is_point_colliding(self, x: float, y: float) -> bool

Determines if the specified point is colliding with the hitbox

perimeter(self) -> float

Returns the perimeter of the hitbox

top_left(self) -> typing.Tuple[float, float]

Returns the top left position of the hitbox

top_right(self) -> typing.Tuple[float, float]

Returns the to _right position of the hitbox

Class BoundHitbox

A bound hitbox will follow and scale along with a derivative of the GameObject class

__init__(self, child: game_object.GameObject)

Parameter child: the object to bind the hitbox to

__repr__(self)

area(self) -> float

Returns the area of the hitbox

bottom_left(self) -> typing.Tuple[float, float]

Returns the bottom left position of the hitbox

bottom_right(self) -> typing.Tuple[float, float]

Returns the bottom right position of the hitbox

diagonal(self)

Returns the diagonal length of the hitbox

draw_hitbox(self, buffer: Surface, color: typing.Tuple[int, int, int] = (255, 255, 255), width: int = 2)

Draws the hitbox to the specified buffer
Parameter buffer:
Parameter color:
Parameter width: the line width to draw the hitbox (use 0 to fill)

is_hitbox_colliding(self, hitbox: Hitbox) -> bool

Determines if the specified hitbox is colliding with the hitbox

is_point_colliding(self, x: float, y: float) -> bool

Determines if the specified point is colliding with the hitbox

perimeter(self) -> float

Returns the perimeter of the hitbox

top_left(self) -> typing.Tuple[float, float]

Returns the top left position of the hitbox

top_right(self) -> typing.Tuple[float, float]

Returns the to _right position of the hitbox