Ball
src.components.ballBall entity with 2D velocity and Arcade rendering.
Ball
Bases: Rectangle
A simple ball represented as a circle; inherits rectangle bounds for AABB.
hits = 0
instance-attribute
last_hit_by_cpu = False
instance-attribute
last_hit_by_player = False
instance-attribute
speed = Vec2(0, 0)
instance-attribute
__init__(left: float, top: float, width: float, height: float)
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
|
Circle diameter. |
required |
height
|
float
|
Circle diameter. |
required |
flip_x() -> None
Invert horizontal velocity.
flip_y() -> None
Invert vertical velocity.
is_going_down() -> bool
Returns True if vertical velocity is downwards in y-down space.
is_going_up() -> bool
Returns True if vertical velocity is upwards in y-down space.
render_to(window_height: float) -> None
Draw as a filled circle using Arcade (convert y-down center to y-up).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window_height
|
float
|
Current window height, used to flip y-axis for Arcade. |
required |
set_speed(value: Vec2) -> None
Assign a new 2D speed vector to the ball.
update_variables() -> None
Integrate velocity into position.