Clean up player.gd: names, comments, grouping, smaller _physics_process #6

Merged
SnekInAScarf merged 1 commit from player-cleanup into main 2026-10-31 20:47:46 -05:00
Owner

Stacked on #5 (→ #4 → #3 → #2): this PR targets floor-hop.

What this does

Tidies up Characters/player.gd with no behaviour change.

Renames

Before After Why
MAX_SECS_TO_UNSTICK HOLD_TIME It times letting go, edge holds, hops and the lip hang, not just unsticking
HOP_MAX_HEIGHT HOP_REACH Also used sideways (walls) and downwards (ceilings)
ROTATE_TO_WALL_SPEED ROTATE_TO_SURFACE_SPEED Used for ceilings too (and now a float)
isClimbingLip isHangingOnLip It's hanging, not climbing
timeSpentUnstickingLip timeSpentOnLip It's how long we've hung there
n, dir wallNormal, direction Match the rest of the file

Consistency

  • CLIMB_SPEED and CEILING_STICK_SPEED are now positive like every other speed; the direction is applied where they're used.
  • Every variable has a type (including sprite: Sprite2D).
  • _accelerate and _air_steer take delta like the other helpers.
  • Magic numbers named: EDGE_SENSOR_DEPTH, LAND_PITCH_MIN / LAND_PITCH_MAX.

Layout

  • Constants and state grouped by feature: movement, sticking, surface edges, edge wrapping, lip, hops, visuals and sound.
  • _physics_process is now a short list of steps: _update_facing, _update_vertical_movement, _update_floor_hop, _update_horizontal_movement, _update_wall_sticking, _update_ceiling_sticking. _finish_wrap is split out of _update_wrap.

Comments

  • Removed the resolved note at the top about unsticking while moving.
  • The lip push is now described as a fallback (lip wraps handle pressing up first).
  • Fixed vague or stale comments and the "aniamtedspite2d" typo.

Testing

  • Behaviour check: a 1180-frame scripted input run over floors, walls, ceilings, ledges, a pillar and a low ceiling, printing position, velocity, surface state, hold timer and sprite rotation every frame, is byte-for-byte identical before and after.
  • Movement suite (39), surface hop tests (13) and ledge drops (88) all pass.
  • test_level.tscn loads and runs.

🤖 Generated with Claude Code

> **Stacked on #5** (→ #4 → #3 → #2): this PR targets `floor-hop`. ## What this does Tidies up `Characters/player.gd` with **no behaviour change**. ### Renames | Before | After | Why | |---|---|---| | `MAX_SECS_TO_UNSTICK` | `HOLD_TIME` | It times letting go, edge holds, hops and the lip hang, not just unsticking | | `HOP_MAX_HEIGHT` | `HOP_REACH` | Also used sideways (walls) and downwards (ceilings) | | `ROTATE_TO_WALL_SPEED` | `ROTATE_TO_SURFACE_SPEED` | Used for ceilings too (and now a float) | | `isClimbingLip` | `isHangingOnLip` | It's hanging, not climbing | | `timeSpentUnstickingLip` | `timeSpentOnLip` | It's how long we've hung there | | `n`, `dir` | `wallNormal`, `direction` | Match the rest of the file | ### Consistency - `CLIMB_SPEED` and `CEILING_STICK_SPEED` are now positive like every other speed; the direction is applied where they're used. - Every variable has a type (including `sprite: Sprite2D`). - `_accelerate` and `_air_steer` take `delta` like the other helpers. - Magic numbers named: `EDGE_SENSOR_DEPTH`, `LAND_PITCH_MIN` / `LAND_PITCH_MAX`. ### Layout - Constants and state grouped by feature: movement, sticking, surface edges, edge wrapping, lip, hops, visuals and sound. - `_physics_process` is now a short list of steps: `_update_facing`, `_update_vertical_movement`, `_update_floor_hop`, `_update_horizontal_movement`, `_update_wall_sticking`, `_update_ceiling_sticking`. `_finish_wrap` is split out of `_update_wrap`. ### Comments - Removed the resolved note at the top about unsticking while moving. - The lip push is now described as a fallback (lip wraps handle pressing up first). - Fixed vague or stale comments and the "aniamtedspite2d" typo. ## Testing - [x] **Behaviour check:** a 1180-frame scripted input run over floors, walls, ceilings, ledges, a pillar and a low ceiling, printing position, velocity, surface state, hold timer and sprite rotation every frame, is **byte-for-byte identical** before and after. - [x] Movement suite (39), surface hop tests (13) and ledge drops (88) all pass. - [x] `test_level.tscn` loads and runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
SnekInAScarf added 1 commit 2026-10-31 19:43:19 -05:00
No behaviour change (a 1180-frame scripted trace is identical before and
after, and all headless tests pass).

- Renames: MAX_SECS_TO_UNSTICK -> HOLD_TIME (it times holds, hops and
  lips too), HOP_MAX_HEIGHT -> HOP_REACH (also sideways/down),
  ROTATE_TO_WALL_SPEED -> ROTATE_TO_SURFACE_SPEED, isClimbingLip ->
  isHangingOnLip, timeSpentUnstickingLip -> timeSpentOnLip, plus
  n/dir -> wallNormal/direction.
- CLIMB_SPEED and CEILING_STICK_SPEED are positive like the other speeds,
  with the direction applied where they're used.
- Missing type annotations added (including sprite: Sprite2D).
- Constants and state grouped by feature; magic numbers for sensor depth
  and landing pitch named.
- _physics_process split into _update_facing, _update_vertical_movement,
  _update_floor_hop, _update_horizontal_movement, _update_wall_sticking
  and _update_ceiling_sticking; _finish_wrap split out of _update_wrap.
- _accelerate/_air_steer take delta like the other helpers.
- Stale and vague comments fixed (lip push marked as a fallback, the
  resolved note at the top removed, typos).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SnekInAScarf changed target branch from floor-hop to main 2026-10-31 20:47:43 -05:00
SnekInAScarf merged commit 90186a6c2e into main 2026-10-31 20:47:46 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: SnekInAScarf/SlimePlatformer#6
No description provided.