Rect¶
Rect is similar glass to Pygame Rect class. Difference is that all values x, y, width and height do allow both integers and floating points.
-
class
pygame_colliders.
Rect
(x: Union[List[float], float], y: Union[List[float], float], w: Union[None, int, float] = None, h: Union[None, int, float] = None)[source]¶ A rectangle to hold simple bounding rectangle around the colliders.
Parameters: - x (int, float, tuple(int/float, int/float)) – x coordinate or tuple of (x,y) coordinates
- y (int, float, tuple(int/float, int/float)) – y coordinate or tuple of (width, height)
- w (float, int or None) – width
- h (float, int or None) – height
-
bottom
¶ Bottom location of rect.
Getter: the location Setter: the new location Type: float, int
-
bottomleft
¶ Bottom left location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
bottomright
¶ Bottom right location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
center
¶ Center location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
centerx
¶ Center x location of rect.
Getter: the location Setter: the new location Type: float, int
-
centery
¶ Center y location of rect.
Getter: the location Setter: the new location Type: float, int
-
collide_rect
(other: pygame_colliders.rect.Rect) → bool[source]¶ Check if current rect collides with other rect :param other: Other rect to test :type other: Rect :return: True if collides, False otherwise :rtype: bool
-
h
¶ Height of rect.
Getter: the location Setter: the new location Type: float, int
-
height
¶ Height of rect.
Getter: the height Setter: the new height Type: float, int
-
left
¶ Left location of rect.
Getter: the location Setter: the new location Type: float, int
-
midbottom
¶ Mid bottom location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
midleft
¶ Mid left location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
midright
¶ Mid right location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
midtop
¶ Mid top location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
right
¶ Right location of rect.
Getter: the location Setter: the new location Type: float, int
-
size
¶ Size of rect.
Getter: the size Setter: the new size Type: tuple(float/int, float/int)
-
top
¶ Top location of rect.
Getter: the location Setter: the new location Type: float, int
-
topleft
¶ Top left location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
topright
¶ Top right location of rect.
Getter: the location Setter: the new location Type: tuple(float/int, float/int)
-
w
¶ Width of the rect.
Getter: the width Setter: the new width Type: float, int
-
width
¶ Width of rect.
Getter: the width Setter: the new width Type: float, int
-
x
¶ x location (left) of rect.
Getter: the location Setter: the new location Type: float, int
-
y
¶ y location (top) of rect.
Getter: the location Setter: the new location Type: float, int