mini_arcade_core.scenes.systems.builtins.brick_breaker

Reusable brick-breaker gameplay helpers.

Classes

BounceHit

Resolved bounce collision information.

PaddleBouncePolicy

Shape outgoing ball direction based on paddle contact point.

BrickState

Mutable brick metadata stored inside a brick field.

BrickField

Dense brick layout with per-cell hit points.

ViewportBounceBinding

Declarative viewport bounce rule for one or more ball-like entities.

ViewportBounceSystem

Reflect ball-like entities from selected viewport sides.

BounceCollisionBinding

Declarative ball-vs-rect bounce rule.

BounceCollisionSystem

Reflect one moving rect from one or more target rects.

BrickFieldCollisionBinding

Declarative ball-vs-brick-field bounce and damage rule.

BrickFieldCollisionSystem

Reflect a ball-like entity from the first hit brick and damage the field.

Functions

resolve_rect_bounce(→ BounceHit | None)

Resolve the shallowest-axis bounce between two overlapping rects.

apply_bounce_hit(→ None)

Reposition and reflect one kinematic entity according to a resolved hit.

reflect_from_viewport(→ tuple[str, Ellipsis])

Reflect one entity from selected viewport sides.

Module Contents

class mini_arcade_core.scenes.systems.builtins.brick_breaker.BounceHit[source]

Resolved bounce collision information.

axis: str
normal_x: float
normal_y: float
penetration: float
mini_arcade_core.scenes.systems.builtins.brick_breaker.resolve_rect_bounce(mover_rect: tuple[float, float, float, float], target_rect: tuple[float, float, float, float]) BounceHit | None[source]

Resolve the shallowest-axis bounce between two overlapping rects.

mini_arcade_core.scenes.systems.builtins.brick_breaker.apply_bounce_hit(entity: mini_arcade_core.engine.entities.BaseEntity, hit: BounceHit) None[source]

Reposition and reflect one kinematic entity according to a resolved hit.

mini_arcade_core.scenes.systems.builtins.brick_breaker.reflect_from_viewport(entity: mini_arcade_core.engine.entities.BaseEntity, *, viewport: tuple[float, float], bounce_left: bool = True, bounce_right: bool = True, bounce_top: bool = True, bounce_bottom: bool = False) tuple[str, Ellipsis][source]

Reflect one entity from selected viewport sides.

class mini_arcade_core.scenes.systems.builtins.brick_breaker.PaddleBouncePolicy[source]

Shape outgoing ball direction based on paddle contact point.

max_bounce_angle_deg: float = 70.0
min_speed: float = 180.0
max_speed: float = 420.0
speed_gain: float = 1.04
vertical_bias: float = 1.0
paddle_velocity_influence: float = 0.25
apply(ball: mini_arcade_core.engine.entities.BaseEntity, paddle: mini_arcade_core.engine.entities.BaseEntity) None[source]

Apply paddle-shaped bounce to a ball-like entity.

class mini_arcade_core.scenes.systems.builtins.brick_breaker.BrickState[source]

Mutable brick metadata stored inside a brick field.

hit_points: int = 1
payload: Any = None
property alive: bool

Return whether this brick still has hit points remaining.

class mini_arcade_core.scenes.systems.builtins.brick_breaker.BrickField[source]

Dense brick layout with per-cell hit points.

layout: mini_arcade_core.scenes.systems.builtins.grid.GridLayout
bricks: dict[mini_arcade_core.scenes.systems.builtins.grid.GridCoord, BrickState]
brick_at(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord) BrickState | None[source]

Return the brick state at one cell, if alive.

occupied_cells() tuple[mini_arcade_core.scenes.systems.builtins.grid.GridCoord, Ellipsis][source]

Return the currently alive brick cells.

brick_rect(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord) tuple[float, float, float, float][source]

Return the world-space rect for one brick cell.

apply_damage(coord: mini_arcade_core.scenes.systems.builtins.grid.GridCoord, amount: int = 1) BrickState | None[source]

Damage one brick cell and delete it when hp reaches zero.

class mini_arcade_core.scenes.systems.builtins.brick_breaker.ViewportBounceBinding[source]

Bases: Generic[TCtx]

Declarative viewport bounce rule for one or more ball-like entities.

entities_getter: Callable[[TCtx], Iterable[mini_arcade_core.engine.entities.BaseEntity]]
viewport_getter: Callable[[TCtx], tuple[float, float]]
predicate: Callable[[TCtx, mini_arcade_core.engine.entities.BaseEntity], bool]
bounce_left: bool = True
bounce_right: bool = True
bounce_top: bool = True
bounce_bottom: bool = False
on_bounce: Callable[[TCtx, mini_arcade_core.engine.entities.BaseEntity, tuple[str, Ellipsis]], None] | None = None
class mini_arcade_core.scenes.systems.builtins.brick_breaker.ViewportBounceSystem[source]

Bases: Generic[TCtx]

Reflect ball-like entities from selected viewport sides.

name: str = 'common_viewport_bounce'
phase: int
order: int = 40
enabled_when: Callable[[TCtx], bool]
bindings: tuple[ViewportBounceBinding[TCtx], Ellipsis] = ()
step(ctx: TCtx) None[source]

Reflect configured entities from the active viewport edges.

class mini_arcade_core.scenes.systems.builtins.brick_breaker.BounceCollisionBinding[source]

Bases: Generic[TCtx]

Declarative ball-vs-rect bounce rule.

mover_getter: Callable[[TCtx], mini_arcade_core.engine.entities.BaseEntity | None]
targets_getter: Callable[[TCtx], Iterable[mini_arcade_core.engine.entities.BaseEntity]]
predicate: Callable[[TCtx, mini_arcade_core.engine.entities.BaseEntity], bool]
stop_after_first_hit: bool = True
on_bounce: Callable[[TCtx, mini_arcade_core.engine.entities.BaseEntity, mini_arcade_core.engine.entities.BaseEntity, BounceHit], None] | None = None
class mini_arcade_core.scenes.systems.builtins.brick_breaker.BounceCollisionSystem[source]

Bases: Generic[TCtx]

Reflect one moving rect from one or more target rects.

name: str = 'common_bounce_collision'
phase: int
order: int = 45
enabled_when: Callable[[TCtx], bool]
bindings: tuple[BounceCollisionBinding[TCtx], Ellipsis] = ()
step(ctx: TCtx) None[source]

Resolve mover collisions against rect targets and bounce them.

class mini_arcade_core.scenes.systems.builtins.brick_breaker.BrickFieldCollisionBinding[source]

Bases: Generic[TCtx]

Declarative ball-vs-brick-field bounce and damage rule.

mover_getter: Callable[[TCtx], mini_arcade_core.engine.entities.BaseEntity | None]
field_getter: Callable[[TCtx], BrickField | None]
damage: int = 1
on_hit: Callable[[TCtx, mini_arcade_core.engine.entities.BaseEntity, mini_arcade_core.scenes.systems.builtins.grid.GridCoord, BrickState | None, BounceHit], None] | None = None
class mini_arcade_core.scenes.systems.builtins.brick_breaker.BrickFieldCollisionSystem[source]

Bases: Generic[TCtx]

Reflect a ball-like entity from the first hit brick and damage the field.

name: str = 'common_brick_field_collision'
phase: int
order: int = 46
enabled_when: Callable[[TCtx], bool]
bindings: tuple[BrickFieldCollisionBinding[TCtx], Ellipsis] = ()
step(ctx: TCtx) None[source]

Bounce a mover from the first hit brick cell and apply damage.