Fix right flipper: mirror its geometry and sweep it per-substep

The right flipper's arm was computed with the same +cos(angle) direction
as the left one, so it pointed into the right wall, off the 480px canvas
- only the left paddle was ever visible/playable.

- add physics.flipper_tip() which mirrors the right flipper (and use it
  in both collision and rendering)
- derive the flipper's surface velocity from actual tip displacement
  (scaled by contact radius), instead of a hand-signed angular formula
- advance flipper angles inside the collision substeps (6/frame while
  pressed) so a fast sweep can't jump past a resting ball; resting balls
  now get a real 'scoop' from either paddle
- verify: pixel probe shows both paddles on screen (L=1007, R=999 blue
  px); physics probe confirms each paddle launches a resting ball
This commit is contained in:
georgios
2026-09-09 16:46:07 +02:00
parent db49b466c2
commit 973dd870fd
14 changed files with 61 additions and 35 deletions
+5 -5
View File
@@ -9,7 +9,7 @@ import pygame
from physics import (CV_W, CV_H, PLAY_L, PLAY_R, PLAY_T, PLAY_B, BALL_R,
CENTER_HOLE, OUTLANE_L, OUTLANE_R, DRAIN_Y, LAUNCH_DIR,
LAUNCH_MIN, LAUNCH_MAX, Table, FLIP_PIVOT_L, FLIP_PIVOT_R,
FLIP_RADIUS, FLIP_LEN)
FLIP_RADIUS, FLIP_LEN, flipper_tip)
import font as pix
# ---------------------------------------------------------------------------
@@ -195,9 +195,7 @@ def draw_sling(surf, s):
def draw_flipper(surf, f, side):
px, py = f["pivot"]
a = f["angle"]
tipx = px + math.cos(a) * f["length"]
tipy = py + math.sin(a) * f["length"]
tipx, tipy = flipper_tip(f)
p0 = (int(px), int(py))
p1 = (int(tipx), int(tipy))
# shadow
@@ -210,7 +208,9 @@ def draw_flipper(surf, f, side):
pygame.draw.circle(surf, C["flipper_d"], (ex, ey), 6)
pygame.draw.circle(surf, C["flipper"], (ex, ey), 4)
# cute stripe near the top edge
nx, ny = -math.sin(a), math.cos(a)
a = f["angle"]
side_sign = -1.0 if side == "R" else 1.0
nx, ny = -math.sin(a) * side_sign, math.cos(a)
hx, hy = int(px + nx * 3), int(py + ny * 3)
tx, ty = int(tipx + nx * 3), int(tipy + ny * 3)
pygame.draw.line(surf, C["flipper_l"], (hx, hy), (tx, ty), 2)