proejct commit

This commit is contained in:
2026-09-24 15:45:31 +02:00
commit 82d52be8a5
63 changed files with 8748 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
"""Tests der Beispielszene."""
import random
from sandbox.config import INTERACTION, TIME_STEP, DemoSceneConfig, Theme
from sandbox.demo import build_demo_scene
from sandbox.interaction import BodyFactory, ToolSettings
from tests.helpers import make_world
def test_demo_scene_fits_into_the_world_and_settles() -> None:
world = make_world(1020, 720)
factory = BodyFactory(world, INTERACTION, Theme().body_palette, random.Random(0))
scene = DemoSceneConfig()
build_demo_scene(factory, ToolSettings.from_config(INTERACTION), scene)
pyramid = scene.pyramid_rows * (scene.pyramid_rows + 1) // 2
assert len(world.bodies) == scene.tower_levels + pyramid + scene.ball_count
for body in world.bodies:
min_x, min_y, max_x, max_y = body.bounds()
assert min_x >= 0 and max_x <= world.width
assert min_y >= 0 and max_y <= world.height
for _ in range(round(4 / TIME_STEP)):
world.step(TIME_STEP)
tower = world.bodies[: scene.tower_levels]
assert all(body.sleeping for body in tower) # der Turm steht ruhig
tops = [body.position.y for body in tower]
assert tops == sorted(tops, reverse=True) # und ist nicht eingestürzt