Rectangle
src.components.rectangleA minimal rectangle with AABB collision and Arcade rendering support.
Note on coordinates: - The simulation/game logic uses a y-down coordinate system (origin top-left) to mirror the original project behavior. - Arcade renders in y-up space (origin bottom-left). We flip y at draw time.
Rectangle
Simple axis-aligned rectangle.
Attributes:
| Name | Type | Description |
|---|---|---|
pos_x |
float
|
X coordinate of center in y-down space. |
pos_y |
float
|
Y coordinate of center in y-down space. |
bottom: float
property
center: tuple[float, float]
property
writable
center_x: float
property
center_y: float
property
color = BLACK
instance-attribute
height = float(height)
instance-attribute
left: float
property
pos_x = float(left + width / 2)
instance-attribute
pos_y = float(top + height / 2)
instance-attribute
right: float
property
top: float
property
width = float(width)
instance-attribute
__init__(left: float, top: float, width: float, height: float)
Initialize with a pygame-like signature: left, top, width, height.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left
|
float
|
Left edge X (y-down space). |
required |
top
|
float
|
Top edge Y (y-down space). |
required |
width
|
float
|
Rectangle width. |
required |
height
|
float
|
Rectangle height. |
required |
collide_rect(other: Rectangle) -> bool
Axis-aligned bounding-box collision with another rectangle (y-down space).
render_to(window_height: float) -> None
Draw as a filled rectangle using Arcade (convert y-down to y-up).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window_height
|
float
|
Current window height, used to flip y-axis for Arcade. |
required |
update_variables() -> None
Hook for subclasses that update position; kept for interface compatibility.