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:
1 parent
de550e1d4d
commit
d970185e75
15 files changed
+613
-342
No files matched your search
+24
-6
@@ -8,6 +8,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
|
||||
from . import config
|
||||
from .difficulty import DEFAULT_DIFFICULTY, Difficulty
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -15,9 +16,11 @@ class Case:
|
||||
"""Ein Koffer im Auflieger.
|
||||
|
||||
``units_w`` / ``units_h`` beschreiben die **aktuelle** Grundfläche in
|
||||
Kasten-Einheiten. Eine Drehung tauscht die beiden Werte – es gibt also
|
||||
keinen zusätzlichen ``rotated``-Schalter, der mit den Massen kollidieren
|
||||
könnte (das war im Altstand eine Fehlerquelle).
|
||||
Kasten-Einheiten. Eine Drehung tauscht die beiden Werte.
|
||||
|
||||
``texture`` merkt sich die Orientierung, in der der Koffer eingelaufen ist.
|
||||
Die Grafik bleibt dadurch immer dieselbe – ein gedrehter Koffer wird nur um
|
||||
90° gedreht gezeichnet und bekommt keine andere Textur.
|
||||
"""
|
||||
|
||||
units_w: int
|
||||
@@ -25,11 +28,16 @@ class Case:
|
||||
x: float
|
||||
y: float
|
||||
color: tuple[int, int, int] = config.CASE_COLORS[0]
|
||||
texture: tuple[int, int] | None = None
|
||||
placed: bool = False
|
||||
snapped: bool = False
|
||||
allow_snap: bool = False
|
||||
can_rotate: bool = True
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if self.texture is None:
|
||||
self.texture = (self.units_w, self.units_h)
|
||||
|
||||
# -- Geometrie ------------------------------------------------------
|
||||
@property
|
||||
def width(self) -> float:
|
||||
@@ -47,16 +55,26 @@ class Case:
|
||||
def bottom(self) -> float:
|
||||
return self.y + self.height
|
||||
|
||||
@property
|
||||
def is_rotated(self) -> bool:
|
||||
"""Steht der Koffer quer zu seiner Textur?"""
|
||||
return (self.units_w, self.units_h) != self.texture
|
||||
|
||||
# -- Bewegung -------------------------------------------------------
|
||||
def move(self, dt: float, wall_x: float) -> None:
|
||||
def move(
|
||||
self,
|
||||
dt: float,
|
||||
wall_x: float,
|
||||
difficulty: Difficulty = DEFAULT_DIFFICULTY,
|
||||
) -> None:
|
||||
"""Bewegt den Koffer nach links, mit Abbremsen kurz vor der Barriere."""
|
||||
if self.placed:
|
||||
return
|
||||
distance = self.x - wall_x
|
||||
speed = (
|
||||
config.CASE_SPEED_FAST
|
||||
difficulty.speed_fast
|
||||
if distance > config.FAST_TO_SLOW_DISTANCE
|
||||
else config.CASE_SPEED_SLOW
|
||||
else difficulty.speed_slow
|
||||
)
|
||||
self.x -= speed * dt
|
||||
if self.x <= wall_x + config.SNAP_THRESHOLD:
|
||||
|
||||
Reference in new issue
Block a user