Simplify the edge wrap: 8 state variables instead of 15 #9

Merged
SnekInAScarf merged 1 commit from simpler-wrap into main 2026-11-01 02:19:41 -06:00
Owner

What this does

Cuts the edge wrap's state from 15 variables to 8 by only storing what can't be worked out from the rest.

Stored now: isWrapping, wrapCorner, wrapFromNormal (the surface we're leaving), wrapOntoNormal (the surface we land on), wrapEntryStart, wrapArcStartAngle, wrapSpeed, wrapDistanceTravelled.

Worked out by small helpers instead:

Removed variable Now
wrapFromDistance, wrapToDistance _wrap_radius()
wrapArcLength _wrap_arc_length() (angle × radius)
wrapEntryLength _wrap_entry_length()
wrapExitOffset _wrap_exit_offset() (back along the surface we left)
wrapFromRotation, wrapToRotation _rotation_for(normal)
wrapFromAngle, wrapToAngle the normals' angles (wrapArcStartAngle covers where the arc begins)

_begin_wrap now takes (corner, fromNormal, ontoNormal[, arcStartAngle]) instead of five loosely related values, and _finish_wrap no longer needs an if/else for the exit direction.

wrapArcStartAngle stays because the wall-top wrap starts part way around the corner (we've already climbed past it), so its arc start can't be worked out from the surface.

Behaviour

  • Identical for floor→wall and wall→ceiling wraps: the 1180-frame scripted trace matches the old code on every frame.
  • Wall-top wrap: ends in exactly the same place in the same number of frames. Mid-wrap it differs by at most ~0.5px and ~4° of sprite rotation, because it now always uses the arc's radius and turns the sprite from the wall's rotation instead of wherever the sprite happened to be.

Testing

  • Movement suite (39), surface hop tests (13), ledge drops (88) and sprite alignment (4) all pass.
  • Dedicated wall-top trace (both sides) compared before/after.
  • test_level.tscn loads and runs.

🤖 Generated with Claude Code

## What this does Cuts the edge wrap's state from **15 variables to 8** by only storing what can't be worked out from the rest. **Stored now:** `isWrapping`, `wrapCorner`, `wrapFromNormal` (the surface we're leaving), `wrapOntoNormal` (the surface we land on), `wrapEntryStart`, `wrapArcStartAngle`, `wrapSpeed`, `wrapDistanceTravelled`. **Worked out by small helpers instead:** | Removed variable | Now | |---|---| | `wrapFromDistance`, `wrapToDistance` | `_wrap_radius()` | | `wrapArcLength` | `_wrap_arc_length()` (angle × radius) | | `wrapEntryLength` | `_wrap_entry_length()` | | `wrapExitOffset` | `_wrap_exit_offset()` (back along the surface we left) | | `wrapFromRotation`, `wrapToRotation` | `_rotation_for(normal)` | | `wrapFromAngle`, `wrapToAngle` | the normals' angles (`wrapArcStartAngle` covers where the arc begins) | `_begin_wrap` now takes `(corner, fromNormal, ontoNormal[, arcStartAngle])` instead of five loosely related values, and `_finish_wrap` no longer needs an if/else for the exit direction. `wrapArcStartAngle` stays because the wall-top wrap starts part way around the corner (we've already climbed past it), so its arc start can't be worked out from the surface. ## Behaviour - **Identical** for floor→wall and wall→ceiling wraps: the 1180-frame scripted trace matches the old code on every frame. - **Wall-top wrap:** ends in exactly the same place in the same number of frames. Mid-wrap it differs by at most ~0.5px and ~4° of sprite rotation, because it now always uses the arc's radius and turns the sprite from the wall's rotation instead of wherever the sprite happened to be. ## Testing - [x] Movement suite (39), surface hop tests (13), ledge drops (88) and sprite alignment (4) all pass. - [x] Dedicated wall-top trace (both sides) compared before/after. - [x] `test_level.tscn` loads and runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
SnekInAScarf added 1 commit 2026-11-01 02:17:47 -06:00
Store only what can't be worked out: the corner, the surface normals we
leave and land on, where we started, where the arc begins, and the speed
and distance travelled. Arc radius and length, entry length, the exit
move and the sprite rotations are now small _wrap_... helpers.

_begin_wrap takes (corner, fromNormal, ontoNormal[, arcStartAngle])
instead of five loosely related values.

Same behaviour, except the wall-top wrap now always uses the arc's radius
(a straight sub-pixel entry instead of easing it during the arc) and turns
the sprite from the wall's rotation rather than wherever it was: at most
~0.5px and ~4 degrees different mid-wrap, ending in the same place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SnekInAScarf merged commit 571196f292 into main 2026-11-01 02:19:41 -06: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#9
No description provided.