Make player.gd easier to read for newer programmers #8

Merged
SnekInAScarf merged 2 commits from beginner-readability into main 2026-10-31 20:47:57 -05:00
Owner

Stacked on #7 (remove the lip): this PR targets remove-lip. If you skip #7, tell me and I'll move this onto #6.

What this does

Makes Characters/player.gd easier to follow for someone new to programming and Godot, with no behaviour change.

Explanations

  • Overview at the top: what the slime can do, the steps of one frame, and a short glossary: Godot's y axis points down, what delta is, normals, tangents, the dot product and raycasts.
  • Section headers (settings, state, nodes, setup, every frame, movement steps, helpers, hops, edges, edge wrap, effects, physics queries), and a plain-English comment on every setting.
  • The maths explained: the hop launch speed (sqrt(2 × gravity × distance), now its own _get_hop_speed), the exponential smoothing on the sprite's rotation, arc length, and how the wall hop lands at the same height.

Formatting

  • No backslash line continuations and no dense one-line if/elses. Long conditions are split into named true/false variables, for example climbedPastWallTop, tryingToLetGo, holdingDown, standingStill and hitHeadOn.
  • One-line if x: y statements are written out as normal blocks.
  • Explicit checks instead of relying on values counting as true or false: horizontalInput == 0.0, hit == null, .is_empty().

Naming

Before After
pos currentPosition
line justInsideSurface
step distanceThisFrame
along inputAlongSurface
offset fromCorner
wrapTravelled wrapDistanceTravelled
toAngle / fromAngle params arcEndAngle / arcStartAngle

Letting go of walls and ceilings now has its own functions (_update_wall_letting_go, _update_ceiling_letting_go) instead of being buried in the movement steps.

Keeps the # FX resources grouping of the sound and particle nodes from your working copy.

Comments trimmed

A second pass shortened the comments and removed ones that just restate the next line, keeping the ones that explain why or non-obvious maths (284 comment lines down to 110). With comments stripped, the code is identical to the first pass.

Testing

  • The 1180-frame scripted trace 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 #7** (remove the lip): this PR targets `remove-lip`. If you skip #7, tell me and I'll move this onto #6. ## What this does Makes `Characters/player.gd` easier to follow for someone new to programming and Godot, with **no behaviour change**. ### Explanations - **Overview at the top:** what the slime can do, the steps of one frame, and a short glossary: Godot's y axis points *down*, what `delta` is, normals, tangents, the dot product and raycasts. - **Section headers** (settings, state, nodes, setup, every frame, movement steps, helpers, hops, edges, edge wrap, effects, physics queries), and a plain-English comment on every setting. - **The maths explained:** the hop launch speed (`sqrt(2 × gravity × distance)`, now its own `_get_hop_speed`), the exponential smoothing on the sprite's rotation, arc length, and how the wall hop lands at the same height. ### Formatting - **No backslash line continuations** and no dense one-line if/elses. Long conditions are split into named true/false variables, for example `climbedPastWallTop`, `tryingToLetGo`, `holdingDown`, `standingStill` and `hitHeadOn`. - One-line `if x: y` statements are written out as normal blocks. - **Explicit checks** instead of relying on values counting as true or false: `horizontalInput == 0.0`, `hit == null`, `.is_empty()`. ### Naming | Before | After | |---|---| | `pos` | `currentPosition` | | `line` | `justInsideSurface` | | `step` | `distanceThisFrame` | | `along` | `inputAlongSurface` | | `offset` | `fromCorner` | | `wrapTravelled` | `wrapDistanceTravelled` | | `toAngle` / `fromAngle` params | `arcEndAngle` / `arcStartAngle` | Letting go of walls and ceilings now has its own functions (`_update_wall_letting_go`, `_update_ceiling_letting_go`) instead of being buried in the movement steps. Keeps the `# FX resources` grouping of the sound and particle nodes from your working copy. ### Comments trimmed A second pass shortened the comments and removed ones that just restate the next line, keeping the ones that explain *why* or non-obvious maths (284 comment lines down to 110). With comments stripped, the code is identical to the first pass. ## Testing - [x] The 1180-frame scripted trace 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 20:09:45 -05:00
No behaviour change (the 1180-frame scripted trace is identical before
and after, and all headless tests pass).

- Overview at the top: what the slime can do, how a frame runs, and a
  glossary (y points down, delta, normal, tangent, dot product, raycast).
- Big section headers; every setting has a plain-English comment.
- No backslash line continuations or dense one-line if/elses: long
  conditions are split into named bools (climbedPastWallTop, holdingDown,
  standingStill, hitHeadOn, ...), one-line ifs are full blocks.
- Explicit checks instead of truthiness (== 0.0, .is_empty(), == null).
- The maths is explained: the hop speed formula (now _get_hop_speed),
  exponential smoothing, arc length, the wall-hop arc.
- Clearer names: pos -> currentPosition, line -> justInsideSurface,
  step -> distanceThisFrame, along -> inputAlongSurface, offset ->
  fromCorner, wrapTravelled -> wrapDistanceTravelled, and the wrap angle
  parameters -> arcStartAngle/arcEndAngle.
- Letting go of walls and ceilings split out of the movement steps into
  _update_wall_letting_go and _update_ceiling_letting_go.
- Keeps the "FX resources" grouping of the sound/particle nodes and
  landSounds from the working copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SnekInAScarf added 1 commit 2026-10-31 20:32:17 -05:00
Only comments and blank lines changed (the code with comments stripped
is identical). Shortened the overview, section headers and longer
explanations, and removed comments that just describe the next line.
Kept the ones explaining why or non-obvious maths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SnekInAScarf changed target branch from remove-lip to main 2026-10-31 20:47:54 -05:00
SnekInAScarf merged commit bec85cefe3 into main 2026-10-31 20:47:57 -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#8
No description provided.