v1.1: Stufen Easy/Normal/Hard mit Auswahlmenü (Hard = altes Tempo). Koffer behalten beim Drehen ihre Textur. Name/Punkteliste entfernt, nur Stufe + Prozent. Endlos: Ergebnis -> "Nochmals?" -> Stufenauswahl, Ende nur per Esc. storage.py und net.py gelöscht, 48 Tests.

This commit is contained in:
Project Bridge committed 2026-11-01 10:48:52 +00:00
1 parent de550e1d4d
commit d970185e75
15 files changed
+613 -342

No files matched your search

+41 -19
View File
@@ -12,13 +12,22 @@ from .sequences import CaseSpec
# --------------------------------------------------------------------------
# Hintergrund-Bänder
# --------------------------------------------------------------------------
def draw_top_bar(surface: pygame.Surface, assets, percent: float) -> None:
def draw_top_bar(surface: pygame.Surface, assets, percent: float, subtitle: str = "") -> None:
surface.fill(
config.COLOR_TOP_BAR, (0, 0, config.SCREEN_WIDTH, config.TOP_BAR_HEIGHT)
)
font = assets.font
title = font.render(config.TITLE_TEXT, True, config.COLOR_WHITE)
surface.blit(title, (40, config.TOP_BAR_HEIGHT // 2 - title.get_height() // 2))
if subtitle:
small = (assets.font_small or font).render(subtitle, True, config.COLOR_WHITE)
surface.blit(
small,
(
40 + title.get_width() + 48,
config.TOP_BAR_HEIGHT // 2 - small.get_height() // 2,
),
)
_draw_progress_bar(surface, assets, percent)
@@ -56,11 +65,21 @@ def draw_background(surface: pygame.Surface, assets) -> None:
)
def draw_bottom_bar(surface: pygame.Surface, assets, upcoming: list[CaseSpec]) -> None:
def clear_bottom_bar(surface: pygame.Surface) -> None:
"""Untere Leiste schwärzen (ohne Inhalt)."""
surface.fill(
config.COLOR_BOTTOM_BAR,
(0, config.TOP_BAR_HEIGHT + config.GAME_AREA_HEIGHT, config.SCREEN_WIDTH, config.BOTTOM_BAR_HEIGHT),
(
0,
config.TOP_BAR_HEIGHT + config.GAME_AREA_HEIGHT,
config.SCREEN_WIDTH,
config.BOTTOM_BAR_HEIGHT,
),
)
def draw_bottom_bar(surface: pygame.Surface, assets, upcoming: list[CaseSpec]) -> None:
clear_bottom_bar(surface)
top = config.SCREEN_HEIGHT - config.BOTTOM_BAR_HEIGHT
label = (assets.font_small or assets.font).render(config.NEXT_LABEL, True, config.COLOR_WHITE)
surface.blit(label, (40, top + 12))
@@ -140,12 +159,19 @@ def _spec_size(spec: CaseSpec) -> tuple[int, int]:
def draw_case(surface: pygame.Surface, assets, case: Case, angle: float = 0.0) -> None:
"""Zeichnet einen Koffer – immer mit **seiner eigenen** Textur.
Ein gedrehter Koffer wird um 90° gedreht gezeichnet, bekommt aber keine
andere Grafik.
"""
x, y = int(case.x), int(case.y)
width, height = int(case.width), int(case.height)
image = assets.case_surface(case.units_w, case.units_h) if assets is not None else None
image = assets.case_surface(*case.texture) if assets is not None else None
if image is None:
pygame.draw.rect(surface, case.color, (x, y, width, height))
return
if case.is_rotated:
image = pygame.transform.rotate(image, -90)
if angle:
rotated = pygame.transform.rotate(image, angle)
surface.blit(rotated, rotated.get_rect(bottomleft=(x, y + height)))
@@ -171,23 +197,26 @@ def draw_hint(surface: pygame.Surface, assets, stack_possible: bool) -> None:
)
def draw_dim(surface: pygame.Surface, alpha: int = 170) -> None:
"""Dunkelt das ganze Bild ab (für Menü und Ergebnis)."""
overlay = pygame.Surface((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
overlay.set_alpha(alpha)
overlay.fill((0, 0, 0))
surface.blit(overlay, (0, 0))
def draw_overlay_lines(
surface: pygame.Surface,
assets,
lines: list[str],
*,
status: str = "",
status_color: tuple[int, int, int] = config.COLOR_ERROR,
) -> None:
overlay = pygame.Surface((config.SCREEN_WIDTH, config.SCREEN_HEIGHT))
overlay.set_alpha(220)
overlay.fill((0, 0, 0))
surface.blit(overlay, (0, 0))
"""Dunkler Schleier mit zentrierten Textzeilen (Ergebnis-Anzeige)."""
draw_dim(surface, 220)
center_y = config.SCREEN_HEIGHT // 2
line_gap = 16
total_height = 0
rendered: list[pygame.Surface] = []
total_height = 0
for line in lines:
image = assets.font.render(line, True, config.COLOR_WHITE)
rendered.append(image)
@@ -196,10 +225,3 @@ def draw_overlay_lines(
for image in rendered:
surface.blit(image, (config.SCREEN_WIDTH // 2 - image.get_width() // 2, y))
y += image.get_height() + line_gap
if status:
small = assets.font_small.render(status, True, status_color)
surface.blit(
small,
(config.SCREEN_WIDTH // 2 - small.get_width() // 2, y + 20),
)