2026-10-14 03:50:16 -05:00
|
|
|
extends CharacterBody2D
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# The slime crawls on floors, walls and ceilings and sticks to them.
|
2026-11-01 02:05:32 -06:00
|
|
|
# Generally the player press away from a surface while holding still to unstick.
|
|
|
|
|
|
|
|
|
|
###############
|
|
|
|
|
## Constants ##
|
|
|
|
|
###############
|
|
|
|
|
const GROUND_SPEED = 150.0
|
2026-10-31 20:32:13 -05:00
|
|
|
const AIR_SPEED = 75.0
|
|
|
|
|
const CLIMB_SPEED = 150.0
|
|
|
|
|
|
|
|
|
|
# Full speed in 4 frames, stopped in 6.
|
2026-10-31 15:37:54 -05:00
|
|
|
const GROUND_ACCEL = GROUND_SPEED / (4.0 / 60.0)
|
|
|
|
|
const GROUND_FRICTION = GROUND_SPEED / (6.0 / 60.0)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Gentler steering in the air. Extra speed from leaving a surface fades slowly.
|
2026-10-31 15:37:54 -05:00
|
|
|
const AIR_ACCEL = 600.0
|
|
|
|
|
const AIR_DRAG = 300.0
|
|
|
|
|
const MAX_FALL_SPEED = 400.0
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# A small push into the wall/ceiling each frame keeps Godot reporting that we're touching it.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
const CEILING_STICK_SPEED = 20.0
|
|
|
|
|
const WALL_STICK_SPEED = 20.0
|
2026-10-31 20:32:13 -05:00
|
|
|
const SURFACE_SNAP_DISTANCE = 4.0 # Drift off a wall/ceiling by up to this and we pull back on.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# How long to hold before letting go, going over an edge, or hopping.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
const HOLD_TIME = 0.5
|
2026-10-31 18:21:31 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# How close an edge must be (from our center) for an edge wrap.
|
2026-11-01 02:05:32 -06:00
|
|
|
const EDGE_SENSOR_RANGE := 12.0
|
2026-10-31 20:32:13 -05:00
|
|
|
const EDGE_SENSOR_DEPTH = 4.0 # How far past our radius the sensors reach into the surface.
|
|
|
|
|
const WRAP_MARGIN = 0.5 # Extra gap from the corner so we don't clip into it.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-11-01 02:05:32 -06:00
|
|
|
const HOP_REACH = 32.0
|
2026-10-31 20:32:13 -05:00
|
|
|
const HOP_NO_CEILING_HEIGHT = 16.0 # Floor hop with nothing in reach, so you can tell it worked.
|
|
|
|
|
const HOP_OVERSHOOT = 2.0 # Aim slightly past the surface so we arrive with some speed and stick.
|
|
|
|
|
|
|
|
|
|
const ROTATE_TO_SURFACE_SPEED = 25.0
|
2026-11-01 12:25:40 -06:00
|
|
|
const MIN_LAND_SPEED_FOR_SPLAT = 60.0
|
2026-10-31 20:32:13 -05:00
|
|
|
const LAND_PITCH_MIN = 0.87
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
const LAND_PITCH_MAX = 1.15
|
|
|
|
|
|
2026-11-01 12:25:40 -06:00
|
|
|
###############
|
|
|
|
|
## Variables ##
|
|
|
|
|
###############
|
2026-10-29 16:25:36 -05:00
|
|
|
var isStickingToWall := false
|
2026-11-01 12:25:40 -06:00
|
|
|
var wallNormalX := 0.0
|
2026-10-29 16:25:36 -05:00
|
|
|
var isStickingToCeiling := false
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
var timeSpentUnstickingWall := 0.0
|
|
|
|
|
var timeSpentUnstickingCeiling := 0.0
|
|
|
|
|
var timeSpentHoldingEdge := 0.0
|
|
|
|
|
var timeSpentHoldingUpOnFloor := 0.0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Right after wrapping onto a wall or ceiling we're usually still holding away
|
|
|
|
|
# from it. That shouldn't count towards letting go until it's released.
|
2026-10-31 14:30:08 -05:00
|
|
|
var ignoreWallUnstickUntilRelease := false
|
2026-10-31 17:02:33 -05:00
|
|
|
var ignoreCeilingUnstickUntilRelease := false
|
2026-10-31 01:54:26 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
var wallFacingY := -1.0 # Last way we moved along a wall (-1 up). Our "facing" on walls.
|
|
|
|
|
var isHoppingAcross := false # No air steering mid-hop, so it lands where it was aimed.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# A wrap is a straight "entry" to the arc, a quarter-circle "arc" around the
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
# corner, then a straight "exit" onto the new surface. Everything else about the
|
|
|
|
|
# path is worked out from these (see the _wrap_... helpers).
|
2026-10-31 14:39:20 -05:00
|
|
|
var isWrapping := false
|
2026-10-31 20:32:13 -05:00
|
|
|
var wrapCorner := Vector2.ZERO
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
var wrapFromNormal := Vector2.UP # The surface we're leaving.
|
2026-10-31 20:32:13 -05:00
|
|
|
var wrapOntoNormal := Vector2.UP # The surface we'll end up on.
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
var wrapEntryStart := Vector2.ZERO # Where we were when the wrap started.
|
|
|
|
|
var wrapArcStartAngle := 0.0 # Angle around the corner where the arc begins.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var wrapSpeed := 0.0
|
|
|
|
|
var wrapDistanceTravelled := 0.0
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-11-01 12:25:40 -06:00
|
|
|
###########
|
|
|
|
|
## Nodes ##
|
|
|
|
|
###########
|
2026-11-01 00:53:42 -05:00
|
|
|
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
@onready var collisionShape: CollisionShape2D = $CollisionShape2D
|
2026-10-31 20:32:13 -05:00
|
|
|
# Edge-finding raycasts, one each side, under a pivot we turn to face the surface we're on.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
@onready var edgeSensors: Node2D = $EdgeSensors
|
|
|
|
|
@onready var leftEdgeSensor: RayCast2D = $EdgeSensors/LeftEdgeSensor
|
|
|
|
|
@onready var rightEdgeSensor: RayCast2D = $EdgeSensors/RightEdgeSensor
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
# FX resources
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
@onready var splatParticles: CPUParticles2D = $SplatParticles
|
|
|
|
|
@onready var landSound: AudioStreamPlayer = $LandSound
|
|
|
|
|
@onready var wrapSound: AudioStreamPlayer = $WrapSound
|
2026-10-31 20:32:13 -05:00
|
|
|
# Placeholder sounds, see Assets/Sounds/CREDITS.txt. One plays at random per landing.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
@export var landSounds: Array[AudioStream] = []
|
|
|
|
|
|
|
|
|
|
|
2026-10-31 15:02:05 -05:00
|
|
|
func _ready() -> void:
|
2026-10-31 15:37:54 -05:00
|
|
|
floor_snap_length = SURFACE_SNAP_DISTANCE
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
var sensorLength := _get_radius() + EDGE_SENSOR_DEPTH
|
2026-11-01 02:05:32 -06:00
|
|
|
leftEdgeSensor.position = Vector2(-EDGE_SENSOR_RANGE, 0)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
leftEdgeSensor.target_position = Vector2(0, sensorLength)
|
2026-11-01 02:05:32 -06:00
|
|
|
rightEdgeSensor.position = Vector2(EDGE_SENSOR_RANGE, 0)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
rightEdgeSensor.target_position = Vector2(0, sensorLength)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Raycasts only ignore their parent, which is the EdgeSensors pivot, not us.
|
2026-10-31 17:54:15 -05:00
|
|
|
leftEdgeSensor.add_exception(self)
|
|
|
|
|
rightEdgeSensor.add_exception(self)
|
2026-10-31 14:39:20 -05:00
|
|
|
|
2026-10-14 03:50:16 -05:00
|
|
|
func _physics_process(delta: float) -> void:
|
2026-11-01 00:53:42 -05:00
|
|
|
var xInput := Input.get_axis("moveLeft", "moveRight")
|
|
|
|
|
var yInput := Input.get_axis("moveDown", "moveUp")
|
2026-10-14 03:50:16 -05:00
|
|
|
|
2026-10-31 14:39:20 -05:00
|
|
|
if isWrapping:
|
|
|
|
|
_update_wrap(delta)
|
|
|
|
|
return
|
|
|
|
|
|
2026-11-01 12:25:40 -06:00
|
|
|
var wasInAir := (_get_surface_normal() == Vector2.ZERO)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if not wasInAir:
|
|
|
|
|
isHoppingAcross = false
|
2026-10-31 15:37:54 -05:00
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
if isStickingToWall and yInput != 0.0:
|
|
|
|
|
wallFacingY = -signf(yInput)
|
|
|
|
|
if _start_edge_wrap(xInput, yInput):
|
2026-10-31 15:02:05 -05:00
|
|
|
return
|
2026-11-01 00:53:42 -05:00
|
|
|
|
|
|
|
|
# Animated Sprite
|
|
|
|
|
_update_facing(xInput, yInput)
|
|
|
|
|
_update_animation(xInput, yInput)
|
|
|
|
|
|
|
|
|
|
_update_vertical_movement(delta, xInput, yInput)
|
|
|
|
|
_update_floor_hop(delta, xInput, yInput)
|
|
|
|
|
_update_horizontal_movement(delta, xInput, yInput)
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
_hold_at_edge(delta)
|
|
|
|
|
|
2026-11-01 12:25:40 -06:00
|
|
|
var wasOnWall := (isStickingToWall and not is_on_floor())
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
var velocityBeforeMove := velocity
|
|
|
|
|
|
|
|
|
|
move_and_slide()
|
|
|
|
|
|
|
|
|
|
_update_wall_sticking(wasOnWall)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
var climbedPastWallTop := wasOnWall and not isStickingToWall and yInput > 0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var tryingToLetGo := timeSpentUnstickingWall >= HOLD_TIME
|
|
|
|
|
if climbedPastWallTop and not tryingToLetGo and _start_wall_top_wrap():
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
return
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 19:44:49 -05:00
|
|
|
_update_ceiling_sticking()
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# In a corner, stick to the ceiling if pressing up, otherwise the wall.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
if isStickingToWall and isStickingToCeiling:
|
2026-11-01 00:53:42 -05:00
|
|
|
if yInput > 0:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
isStickingToWall = false
|
|
|
|
|
else:
|
|
|
|
|
isStickingToCeiling = false
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
|
|
|
|
var normal := _get_surface_normal()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var landedOnSomething := wasInAir and normal != Vector2.ZERO
|
|
|
|
|
if landedOnSomething:
|
|
|
|
|
var impactSpeed := velocityBeforeMove.dot(-normal)
|
2026-11-01 12:25:40 -06:00
|
|
|
if impactSpeed >= MIN_LAND_SPEED_FOR_SPLAT:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
_splat(normal)
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
|
|
|
|
_update_sprite_rotation(delta)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Movement steps (in the order _physics_process runs them) ----
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
func _update_facing(xInput: float, yInput: float) -> void:
|
|
|
|
|
if xInput == 0.0 and yInput == 0.0:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
return
|
2026-11-01 00:53:42 -05:00
|
|
|
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if isStickingToCeiling:
|
2026-11-01 00:53:42 -05:00
|
|
|
sprite.flip_h = xInput > 0 # Upside down, so flipped the other way.
|
|
|
|
|
elif isStickingToWall:
|
2026-11-01 12:25:40 -06:00
|
|
|
if wallNormalX < 0: sprite.flip_h = yInput < 0
|
|
|
|
|
else: sprite.flip_h = yInput > 0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
else:
|
2026-11-01 00:53:42 -05:00
|
|
|
sprite.flip_h = xInput < 0
|
|
|
|
|
|
|
|
|
|
func _update_animation(xInput:float, yInput:float):
|
|
|
|
|
if xInput and (isStickingToCeiling or is_on_floor()):
|
|
|
|
|
sprite.play("Moving")
|
|
|
|
|
elif yInput and isStickingToWall:
|
|
|
|
|
sprite.play("Moving")
|
|
|
|
|
else:
|
|
|
|
|
sprite.play("Idle")
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
func _update_vertical_movement(delta: float, xInput: float, yInput: float) -> void:
|
2026-10-29 16:25:36 -05:00
|
|
|
if isStickingToCeiling:
|
2026-11-01 00:53:42 -05:00
|
|
|
_update_ceiling_letting_go(delta, xInput, yInput)
|
2026-10-29 16:25:36 -05:00
|
|
|
elif isStickingToWall:
|
2026-11-01 00:53:42 -05:00
|
|
|
var targetSpeed := -CLIMB_SPEED * yInput
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
velocity.y = _accelerate(velocity.y, targetSpeed, delta)
|
2026-10-14 03:50:16 -05:00
|
|
|
elif not is_on_floor():
|
2026-10-31 15:37:54 -05:00
|
|
|
velocity.y = minf(velocity.y + get_gravity().y * delta, MAX_FALL_SPEED)
|
2026-10-14 03:50:16 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Holding down (not moving) for HOLD_TIME lets go, hopping onto a floor if one's in reach.
|
2026-11-01 00:53:42 -05:00
|
|
|
func _update_ceiling_letting_go(delta: float, xInput: float, yInput: float) -> void:
|
|
|
|
|
if yInput >= 0:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
ignoreCeilingUnstickUntilRelease = false
|
|
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
var holdingDown := yInput < 0
|
|
|
|
|
var standingStill := xInput == 0.0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if holdingDown and standingStill and not ignoreCeilingUnstickUntilRelease:
|
|
|
|
|
timeSpentUnstickingCeiling += delta
|
|
|
|
|
else:
|
|
|
|
|
timeSpentUnstickingCeiling = 0.0
|
|
|
|
|
|
|
|
|
|
if timeSpentUnstickingCeiling < HOLD_TIME:
|
|
|
|
|
velocity.y = -CEILING_STICK_SPEED
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
isStickingToCeiling = false
|
|
|
|
|
var floorDistance := _get_hop_distance(Vector2.DOWN)
|
|
|
|
|
if floorDistance >= 0.0:
|
|
|
|
|
velocity.y = _get_hop_speed(floorDistance)
|
|
|
|
|
else:
|
|
|
|
|
velocity.y = get_gravity().y * delta
|
|
|
|
|
|
2026-11-01 02:05:32 -06:00
|
|
|
# Hopping from the floop while holding still.
|
2026-11-01 00:53:42 -05:00
|
|
|
func _update_floor_hop(delta: float, xInput: float, yInput: float) -> void:
|
2026-11-01 02:05:32 -06:00
|
|
|
if is_on_floor() and not isStickingToWall and xInput == 0.0 and yInput > 0:
|
2026-10-31 18:27:44 -05:00
|
|
|
timeSpentHoldingUpOnFloor += delta
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
else:
|
|
|
|
|
timeSpentHoldingUpOnFloor = 0.0
|
|
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
if timeSpentHoldingUpOnFloor >= HOLD_TIME:
|
2026-10-31 18:21:31 -05:00
|
|
|
timeSpentHoldingUpOnFloor = 0.0
|
2026-10-31 20:32:13 -05:00
|
|
|
velocity.y = -_get_hop_speed(_get_hop_height())
|
2026-10-31 18:21:31 -05:00
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
func _update_horizontal_movement(delta: float, xInput: float, yInput: float) -> void:
|
2026-10-29 16:25:36 -05:00
|
|
|
if isStickingToWall and not is_on_floor():
|
2026-11-01 00:53:42 -05:00
|
|
|
_update_wall_letting_go(delta, xInput, yInput)
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
return
|
2026-10-29 03:28:37 -05:00
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
timeSpentUnstickingWall = 0.0
|
2026-10-31 19:44:49 -05:00
|
|
|
if is_on_floor() or isStickingToCeiling:
|
2026-11-01 00:53:42 -05:00
|
|
|
velocity.x = _accelerate(velocity.x, xInput * GROUND_SPEED, delta)
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
elif not isHoppingAcross:
|
2026-11-01 00:53:42 -05:00
|
|
|
velocity.x = _air_steer(velocity.x, xInput, delta)
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Holding away (not climbing) for HOLD_TIME hops to the opposite wall if one's
|
|
|
|
|
# in reach, otherwise lets go.
|
2026-11-01 00:53:42 -05:00
|
|
|
func _update_wall_letting_go(delta: float, xInput: float, yInput: float) -> void:
|
|
|
|
|
var pressingAwayFromWall := xInput * wallNormalX > 0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if not pressingAwayFromWall:
|
|
|
|
|
ignoreWallUnstickUntilRelease = false
|
|
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
var standingStill := yInput == 0.0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if pressingAwayFromWall and standingStill and not ignoreWallUnstickUntilRelease:
|
|
|
|
|
timeSpentUnstickingWall += delta
|
|
|
|
|
else:
|
|
|
|
|
timeSpentUnstickingWall = 0.0
|
|
|
|
|
|
|
|
|
|
if timeSpentUnstickingWall < HOLD_TIME:
|
|
|
|
|
velocity.x = -wallNormalX * WALL_STICK_SPEED
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
var wallDistance := _get_hop_distance(Vector2(wallNormalX, 0))
|
|
|
|
|
if wallDistance >= 0.0:
|
|
|
|
|
_hop_across(wallDistance)
|
|
|
|
|
else:
|
2026-11-01 00:53:42 -05:00
|
|
|
velocity.x = xInput * GROUND_SPEED
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _update_wall_sticking(wasOnWall: bool) -> void:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var meantToLetGo := timeSpentUnstickingWall >= HOLD_TIME
|
|
|
|
|
var driftedBackOn := false
|
|
|
|
|
if wasOnWall and not meantToLetGo and not is_on_wall():
|
|
|
|
|
driftedBackOn = _snap_to_surface(Vector2(wallNormalX, 0))
|
|
|
|
|
|
|
|
|
|
isStickingToWall = is_on_wall() or driftedBackOn
|
|
|
|
|
if isStickingToWall:
|
|
|
|
|
wallNormalX = get_wall_normal().x
|
|
|
|
|
|
2026-10-31 19:44:49 -05:00
|
|
|
func _update_ceiling_sticking() -> void:
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
var wasOnCeiling := isStickingToCeiling
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var driftedBackOn := false
|
|
|
|
|
if wasOnCeiling and not is_on_ceiling():
|
|
|
|
|
driftedBackOn = _snap_to_surface(Vector2.DOWN)
|
|
|
|
|
isStickingToCeiling = is_on_ceiling() or driftedBackOn
|
2026-10-29 16:25:36 -05:00
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _update_sprite_rotation(delta: float) -> void:
|
2026-10-31 20:32:13 -05:00
|
|
|
var targetRotation := 0.0
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if isStickingToWall and not is_on_floor():
|
2026-10-31 20:32:13 -05:00
|
|
|
targetRotation = PI / 2 * wallNormalX
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
elif isStickingToCeiling:
|
2026-10-31 20:32:13 -05:00
|
|
|
targetRotation = PI
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Smooth, and the same speed at any frame rate thanks to exp().
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var turnAmount := 1.0 - exp(-ROTATE_TO_SURFACE_SPEED * delta)
|
|
|
|
|
sprite.rotation = lerp_angle(sprite.rotation, targetRotation, turnAmount)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Movement helpers ----
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# GROUND_ACCEL when speeding up, GROUND_FRICTION when slowing, stopping or turning.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
func _accelerate(speed: float, targetSpeed: float, delta: float) -> float:
|
|
|
|
|
var goingSameWay := speed == 0.0 or signf(targetSpeed) == signf(speed)
|
|
|
|
|
var speedingUp := targetSpeed != 0.0 and goingSameWay and absf(targetSpeed) > absf(speed)
|
|
|
|
|
var rate := GROUND_ACCEL if speedingUp else GROUND_FRICTION
|
|
|
|
|
return move_toward(speed, targetSpeed, rate * delta)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Extra speed from leaving a surface fades slowly unless we steer against it.
|
2026-11-01 00:53:42 -05:00
|
|
|
func _air_steer(speed: float, xInput: float, delta: float) -> float:
|
|
|
|
|
var targetSpeed := xInput * AIR_SPEED
|
|
|
|
|
var steeringSameWay := xInput == 0.0 or signf(xInput) == signf(speed)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var hasExtraSpeed := absf(speed) > AIR_SPEED
|
2026-11-01 00:53:42 -05:00
|
|
|
if (hasExtraSpeed and steeringSameWay) or xInput == 0.0:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
return move_toward(speed, targetSpeed, AIR_DRAG * delta)
|
|
|
|
|
return move_toward(speed, targetSpeed, AIR_ACCEL * delta)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Moves flush against the surface with this normal if it's within SURFACE_SNAP_DISTANCE.
|
2026-10-31 15:37:54 -05:00
|
|
|
func _snap_to_surface(normal: Vector2) -> bool:
|
2026-10-31 20:32:13 -05:00
|
|
|
var hit := move_and_collide(-normal * SURFACE_SNAP_DISTANCE, true) # true = test only, don't move.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if hit == null:
|
|
|
|
|
return false
|
2026-10-31 20:32:13 -05:00
|
|
|
# Only head-on, so catching the corner of an edge we're leaving doesn't pull us around it.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var hitHeadOn := hit.get_normal().dot(normal) >= 0.9
|
|
|
|
|
if not hitHeadOn:
|
|
|
|
|
return false
|
2026-10-31 15:37:54 -05:00
|
|
|
global_position += hit.get_travel()
|
|
|
|
|
return true
|
|
|
|
|
|
2026-10-31 15:11:14 -05:00
|
|
|
func _get_surface_normal() -> Vector2:
|
2026-11-01 02:05:32 -06:00
|
|
|
if is_on_floor(): return Vector2.UP
|
|
|
|
|
if isStickingToCeiling: return Vector2.DOWN
|
|
|
|
|
if isStickingToWall: return Vector2(wallNormalX, 0)
|
2026-10-31 15:11:14 -05:00
|
|
|
return Vector2.ZERO
|
|
|
|
|
|
|
|
|
|
func _get_facing() -> Vector2:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if is_on_floor():
|
|
|
|
|
if sprite.flip_h:
|
|
|
|
|
return Vector2.LEFT
|
|
|
|
|
return Vector2.RIGHT
|
|
|
|
|
if isStickingToCeiling:
|
|
|
|
|
if sprite.flip_h:
|
|
|
|
|
return Vector2.RIGHT
|
|
|
|
|
return Vector2.LEFT
|
2026-10-31 15:11:14 -05:00
|
|
|
return Vector2(0, wallFacingY)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Hops ----
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _get_hop_height() -> float:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var ceilingDistance := _get_hop_distance(Vector2.UP)
|
|
|
|
|
if ceilingDistance >= 0.0:
|
|
|
|
|
return ceilingDistance
|
|
|
|
|
return HOP_NO_CEILING_HEIGHT
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Distance to a surface facing us within HOP_REACH (plus HOP_OVERSHOOT), or -1 if none.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _get_hop_distance(direction: Vector2) -> float:
|
|
|
|
|
var hit := move_and_collide(direction * HOP_REACH, true)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if hit == null:
|
|
|
|
|
return -1.0
|
|
|
|
|
var facingUs := hit.get_normal().dot(-direction) > 0.5
|
|
|
|
|
if not facingUs:
|
|
|
|
|
return -1.0
|
|
|
|
|
return hit.get_travel().length() + HOP_OVERSHOOT
|
|
|
|
|
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Launch speed for gravity to stop us after `distance`: sqrt(2 x gravity x distance).
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
func _get_hop_speed(distance: float) -> float:
|
|
|
|
|
return sqrt(2.0 * get_gravity().y * distance)
|
|
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Sideways at crawling speed, with enough upward speed that gravity brings us
|
|
|
|
|
# back to the same height as we arrive.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _hop_across(distance: float) -> void:
|
|
|
|
|
var flightTime := distance / GROUND_SPEED
|
|
|
|
|
velocity.x = wallNormalX * GROUND_SPEED
|
|
|
|
|
velocity.y = -0.5 * get_gravity().y * flightTime
|
|
|
|
|
isHoppingAcross = true
|
|
|
|
|
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Edges ----
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Pressing into the surface near an edge starts wrapping around it. A direction
|
|
|
|
|
# along the surface picks the side, otherwise facing does (or the other side if
|
|
|
|
|
# only it has an edge).
|
2026-11-01 00:53:42 -05:00
|
|
|
func _start_edge_wrap(xInput: float, yInput: float) -> bool:
|
2026-10-31 15:11:14 -05:00
|
|
|
var normal := _get_surface_normal()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if normal == Vector2.ZERO:
|
2026-10-31 20:32:13 -05:00
|
|
|
return false
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-11-01 00:53:42 -05:00
|
|
|
var inputDirection := Vector2(xInput, -yInput) # Up is negative y.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var pressingIntoSurface := inputDirection.dot(-normal) >= 0.5
|
|
|
|
|
if not pressingIntoSurface:
|
|
|
|
|
return false
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Point the sensors into the surface. Their local +x now runs along it.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
edgeSensors.rotation = normal.angle() + PI / 2
|
2026-10-31 15:11:14 -05:00
|
|
|
var tangent := Vector2.from_angle(edgeSensors.rotation)
|
|
|
|
|
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var inputAlongSurface := inputDirection.dot(tangent)
|
|
|
|
|
if absf(inputAlongSurface) >= 0.5:
|
|
|
|
|
return _try_edge_wrap(normal, tangent, signf(inputAlongSurface))
|
|
|
|
|
|
|
|
|
|
var facingSide := 1.0
|
|
|
|
|
if _get_facing().dot(tangent) < 0:
|
|
|
|
|
facingSide = -1.0
|
|
|
|
|
if _try_edge_wrap(normal, tangent, facingSide):
|
|
|
|
|
return true
|
|
|
|
|
return _try_edge_wrap(normal, tangent, -facingSide)
|
|
|
|
|
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# side: 1 for the sensor along the tangent, -1 for the other.
|
2026-10-31 15:11:14 -05:00
|
|
|
func _try_edge_wrap(normal: Vector2, tangent: Vector2, side: float) -> bool:
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var sensor := leftEdgeSensor
|
|
|
|
|
if side > 0:
|
|
|
|
|
sensor = rightEdgeSensor
|
|
|
|
|
|
2026-10-31 15:02:05 -05:00
|
|
|
sensor.force_raycast_update()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if sensor.is_colliding():
|
2026-10-31 20:32:13 -05:00
|
|
|
return false # Still over the surface: no edge.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if not _is_point_free(sensor.global_position):
|
2026-10-31 20:32:13 -05:00
|
|
|
return false # Starts inside something: an inside corner, not an edge.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
var direction := tangent * side
|
2026-11-01 02:05:32 -06:00
|
|
|
var corner = _find_edge_corner(normal, direction, EDGE_SENSOR_RANGE + 2)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if corner == null:
|
|
|
|
|
return false
|
|
|
|
|
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
# Off the surface we're on, onto the side of the platform past the edge.
|
|
|
|
|
return _begin_wrap(corner, normal, direction)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 17:02:33 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# The corner where our surface ends, if within `reach` ahead in `direction`, else null.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _find_edge_corner(normal: Vector2, direction: Vector2, reach: float) -> Variant:
|
2026-10-31 15:02:05 -05:00
|
|
|
var radius := _get_radius()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var currentPosition := global_position
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# 1. Find our surface with a ray from slightly behind us.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var rayStart := currentPosition - direction * radius * 0.5
|
|
|
|
|
var surfaceHit := _cast_ray(rayStart, rayStart - normal * radius * 2)
|
|
|
|
|
if surfaceHit.is_empty() or surfaceHit.normal.dot(normal) < 0.5:
|
|
|
|
|
return null
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# 2. Find the platform's side with a ray from `reach` ahead back towards us,
|
|
|
|
|
# 2px inside the surface. If the surface goes on past `reach`, the ray
|
|
|
|
|
# starts inside it and hits nothing.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var surfacePoint: Vector2 = surfaceHit.position
|
|
|
|
|
var howFarAhead := (currentPosition - surfacePoint).dot(direction)
|
|
|
|
|
var justInsideSurface := surfacePoint - normal * 2 + direction * howFarAhead
|
|
|
|
|
var sideHit := _cast_ray(justInsideSurface + direction * reach, justInsideSurface - direction * radius)
|
|
|
|
|
if sideHit.is_empty() or sideHit.normal.dot(direction) < 0.5:
|
|
|
|
|
return null
|
|
|
|
|
var corner: Vector2 = sideHit.position + normal * 2
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# 3. A real edge has empty space past it. Tile seams and the foot of a wall don't.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if not _is_point_free(corner + direction * 2 - normal * 2):
|
|
|
|
|
return null
|
2026-10-31 17:14:07 -05:00
|
|
|
return corner
|
2026-10-31 17:02:33 -05:00
|
|
|
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Stops us at an edge we'd cross this frame, until we've held towards it for HOLD_TIME.
|
2026-10-31 17:02:33 -05:00
|
|
|
func _hold_at_edge(delta: float) -> void:
|
|
|
|
|
var normal := _get_surface_normal()
|
2026-10-31 20:32:13 -05:00
|
|
|
var tangent := normal.orthogonal()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var speedAlongSurface := velocity.dot(tangent)
|
|
|
|
|
if normal == Vector2.ZERO or is_zero_approx(speedAlongSurface):
|
2026-10-31 17:02:33 -05:00
|
|
|
timeSpentHoldingEdge = 0.0
|
2026-10-31 20:32:13 -05:00
|
|
|
return
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
var direction := tangent * signf(speedAlongSurface)
|
2026-10-31 20:32:13 -05:00
|
|
|
# Climbing past a wall's top swings over it instead (_start_wall_top_wrap).
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var onWall := absf(normal.x) > 0.5
|
|
|
|
|
if onWall and direction.y < 0:
|
2026-10-31 17:02:33 -05:00
|
|
|
return
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
var distanceThisFrame := absf(speedAlongSurface) * delta
|
|
|
|
|
var corner = _find_edge_corner(normal, direction, distanceThisFrame + 1)
|
2026-10-31 20:32:13 -05:00
|
|
|
var distanceToEdge := INF
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if corner != null:
|
|
|
|
|
distanceToEdge = (corner - global_position).dot(direction)
|
|
|
|
|
if distanceToEdge > distanceThisFrame:
|
2026-10-31 17:02:33 -05:00
|
|
|
timeSpentHoldingEdge = 0.0
|
2026-10-31 20:32:13 -05:00
|
|
|
return
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
if timeSpentHoldingEdge >= HOLD_TIME:
|
2026-10-31 20:32:13 -05:00
|
|
|
return
|
2026-10-31 17:02:33 -05:00
|
|
|
timeSpentHoldingEdge += delta
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Set our speed along the surface to stop exactly at the edge.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var speedToReachEdge := maxf(distanceToEdge, 0.0) / delta
|
|
|
|
|
velocity += direction * (speedToReachEdge - absf(speedAlongSurface))
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# We've just climbed past a wall's top corner, so _find_edge_corner (which looks
|
|
|
|
|
# from the surface we're on) can't see it. Find it with our own raycasts.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _start_wall_top_wrap() -> bool:
|
|
|
|
|
var wallNormal := wallNormalX
|
|
|
|
|
var radius := _get_radius()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var currentPosition := global_position
|
|
|
|
|
|
|
|
|
|
var aboveTop := currentPosition + Vector2(-wallNormal * (radius + 2), -radius)
|
|
|
|
|
var topHit := _cast_ray(aboveTop, aboveTop + Vector2(0, radius * 3))
|
|
|
|
|
if topHit.is_empty() or topHit.normal.y > -0.5:
|
|
|
|
|
return false
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
var topY: float = topHit.position.y
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
var besideWall := Vector2(currentPosition.x + wallNormal * 2, topY + 2)
|
|
|
|
|
var sideHit := _cast_ray(besideWall, Vector2(currentPosition.x - wallNormal * radius * 2, topY + 2))
|
|
|
|
|
if sideHit.is_empty() or sideHit.normal.x * wallNormal < 0.5:
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
var corner := Vector2(sideHit.position.x, topY)
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
# We're already part way around the corner, so start the arc from where we are.
|
|
|
|
|
var arcStartAngle := (currentPosition - corner).angle()
|
|
|
|
|
return _begin_wrap(corner, Vector2(wallNormal, 0), Vector2.UP, arcStartAngle)
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Edge wrap ----
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
# Swings around `corner`, from the surface facing fromNormal onto the one facing
|
|
|
|
|
# ontoNormal. First moves straight to the start of the arc (at arcStartAngle
|
|
|
|
|
# around the corner, or straight out from the surface we're leaving if not
|
|
|
|
|
# given). Returns false if there's no room at the end.
|
|
|
|
|
func _begin_wrap(corner: Vector2, fromNormal: Vector2, ontoNormal: Vector2, arcStartAngle := NAN) -> bool:
|
|
|
|
|
# Round to exact directions, e.g. (1, 0.0000001) to (1, 0).
|
|
|
|
|
fromNormal = fromNormal.round()
|
|
|
|
|
ontoNormal = ontoNormal.round()
|
|
|
|
|
|
|
|
|
|
var endPosition := corner + ontoNormal * _wrap_radius() - fromNormal * _get_radius()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
if not _is_spot_free(endPosition):
|
|
|
|
|
return false
|
|
|
|
|
|
2026-10-31 14:39:20 -05:00
|
|
|
wrapCorner = corner
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
wrapFromNormal = fromNormal
|
2026-10-31 15:11:14 -05:00
|
|
|
wrapOntoNormal = ontoNormal
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
wrapEntryStart = global_position
|
|
|
|
|
if is_nan(arcStartAngle): # NAN ("not a number") means it wasn't given.
|
|
|
|
|
arcStartAngle = fromNormal.angle()
|
|
|
|
|
wrapArcStartAngle = arcStartAngle
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
wrapDistanceTravelled = 0.0
|
2026-10-31 20:32:13 -05:00
|
|
|
wrapSpeed = minf(velocity.length(), GROUND_SPEED) # Keep our speed going in.
|
2026-10-31 14:39:20 -05:00
|
|
|
velocity = Vector2.ZERO
|
|
|
|
|
isWrapping = true
|
2026-10-31 15:37:54 -05:00
|
|
|
wrapSound.play()
|
2026-10-31 14:39:20 -05:00
|
|
|
return true
|
|
|
|
|
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 14:39:20 -05:00
|
|
|
func _update_wrap(delta: float) -> void:
|
2026-10-31 15:37:54 -05:00
|
|
|
wrapSpeed = move_toward(wrapSpeed, GROUND_SPEED, GROUND_ACCEL * delta)
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
var entryLength := _wrap_entry_length()
|
|
|
|
|
var arcLength := _wrap_arc_length()
|
|
|
|
|
var exitOffset := _wrap_exit_offset()
|
|
|
|
|
var totalLength := entryLength + arcLength + exitOffset.length()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
wrapDistanceTravelled = minf(wrapDistanceTravelled + wrapSpeed * delta, totalLength)
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Entry.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var distance := wrapDistanceTravelled
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
if distance < entryLength:
|
|
|
|
|
global_position = wrapEntryStart.lerp(_wrap_arc_start(), distance / entryLength)
|
2026-10-31 15:02:05 -05:00
|
|
|
return
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
distance -= entryLength
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Arc. Progress goes from 0 to 1.
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var arcProgress := 1.0
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
if arcLength > 0.0:
|
|
|
|
|
arcProgress = minf(distance / arcLength, 1.0)
|
|
|
|
|
var angle := lerp_angle(wrapArcStartAngle, wrapOntoNormal.angle(), arcProgress)
|
|
|
|
|
var positionOnArc := wrapCorner + Vector2.from_angle(angle) * _wrap_radius()
|
|
|
|
|
sprite.rotation = lerp_angle(_rotation_for(wrapFromNormal), _rotation_for(wrapOntoNormal), arcProgress)
|
2026-10-31 14:39:20 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Exit.
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
var exitProgress := maxf(distance - arcLength, 0.0) / exitOffset.length()
|
|
|
|
|
global_position = positionOnArc + exitOffset * exitProgress
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
if wrapDistanceTravelled >= totalLength:
|
|
|
|
|
_finish_wrap(delta)
|
|
|
|
|
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
|
|
|
|
|
# ---- Wrap path, worked out from the wrap... variables ----
|
|
|
|
|
|
|
|
|
|
# How far from the corner the arc keeps us.
|
|
|
|
|
func _wrap_radius() -> float:
|
|
|
|
|
return _get_radius() + WRAP_MARGIN
|
|
|
|
|
|
|
|
|
|
func _wrap_arc_start() -> Vector2:
|
|
|
|
|
return wrapCorner + Vector2.from_angle(wrapArcStartAngle) * _wrap_radius()
|
|
|
|
|
|
|
|
|
|
func _wrap_entry_length() -> float:
|
|
|
|
|
return wrapEntryStart.distance_to(_wrap_arc_start())
|
|
|
|
|
|
|
|
|
|
# The arc ends pointing straight out of the new surface. Arc length = angle x radius.
|
|
|
|
|
func _wrap_arc_length() -> float:
|
|
|
|
|
return absf(angle_difference(wrapArcStartAngle, wrapOntoNormal.angle())) * _wrap_radius()
|
|
|
|
|
|
|
|
|
|
# After the arc, carry on along the new surface (away from the one we left) so
|
|
|
|
|
# our side ends up flat against it.
|
|
|
|
|
func _wrap_exit_offset() -> Vector2:
|
|
|
|
|
return -wrapFromNormal * _get_radius()
|
|
|
|
|
|
|
|
|
|
# The sprite rotation for standing on a surface with this normal, kept between -PI and PI.
|
|
|
|
|
func _rotation_for(normal: Vector2) -> float:
|
|
|
|
|
return wrapf(normal.angle() + PI / 2, -PI, PI)
|
|
|
|
|
|
|
|
|
|
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _finish_wrap(delta: float) -> void:
|
2026-10-31 20:32:13 -05:00
|
|
|
# Close the WRAP_MARGIN gap with move_and_slide() so is_on_floor()/is_on_wall()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
# describe where we are now, not where we were before the wrap.
|
2026-10-31 15:11:14 -05:00
|
|
|
velocity = -wrapOntoNormal * (WRAP_MARGIN + 1) / delta
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Godot still thinks we're on the floor we started from, so it would snap us
|
|
|
|
|
# down to it and count the wall as floor (floor_block_on_wall). Turn both off
|
|
|
|
|
# for this move unless we're ending on a floor.
|
2026-10-31 19:24:11 -05:00
|
|
|
var endingOnFloor := wrapOntoNormal == Vector2.UP
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
var savedFloorSnap := floor_snap_length
|
|
|
|
|
var savedBlockOnWall := floor_block_on_wall
|
2026-10-31 19:24:11 -05:00
|
|
|
if not endingOnFloor:
|
|
|
|
|
floor_snap_length = 0.0
|
|
|
|
|
floor_block_on_wall = false
|
2026-10-31 15:02:05 -05:00
|
|
|
move_and_slide()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
floor_snap_length = savedFloorSnap
|
|
|
|
|
floor_block_on_wall = savedBlockOnWall
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Keep our speed along the new surface so leaving the wrap isn't a sudden stop.
|
Simplify the edge wrap: 8 state variables instead of 15
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>
2026-11-01 02:13:01 -06:00
|
|
|
velocity = -wrapFromNormal * wrapSpeed
|
2026-10-31 14:46:08 -05:00
|
|
|
|
2026-10-31 14:39:20 -05:00
|
|
|
isWrapping = false
|
2026-10-31 15:11:14 -05:00
|
|
|
isStickingToCeiling = wrapOntoNormal.y > 0.5
|
|
|
|
|
isStickingToWall = absf(wrapOntoNormal.x) > 0.5
|
2026-10-31 14:39:20 -05:00
|
|
|
if isStickingToWall:
|
2026-10-31 15:11:14 -05:00
|
|
|
wallNormalX = wrapOntoNormal.x
|
2026-10-31 14:39:20 -05:00
|
|
|
ignoreWallUnstickUntilRelease = true
|
2026-10-31 17:02:33 -05:00
|
|
|
ignoreCeilingUnstickUntilRelease = isStickingToCeiling
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Effects ----
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
|
|
|
|
func _splat(normal: Vector2) -> void:
|
|
|
|
|
splatParticles.global_position = global_position - normal * _get_radius()
|
2026-10-31 20:32:13 -05:00
|
|
|
splatParticles.reset_physics_interpolation() # A jump, not movement: don't smooth from the last spot.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
splatParticles.direction = normal
|
|
|
|
|
splatParticles.restart()
|
Make player.gd easier to read for newer programmers
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>
2026-10-31 20:09:43 -05:00
|
|
|
|
|
|
|
|
if not landSounds.is_empty():
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
landSound.stream = landSounds.pick_random()
|
|
|
|
|
landSound.pitch_scale = randf_range(LAND_PITCH_MIN, LAND_PITCH_MAX)
|
|
|
|
|
landSound.play()
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# ---- Physics queries (all ignore the slime itself) ----
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
|
|
|
|
|
func _get_radius() -> float:
|
|
|
|
|
return (collisionShape.shape as CircleShape2D).radius
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Returns the hit (.position, .normal), or an empty Dictionary if nothing.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _cast_ray(from: Vector2, to: Vector2) -> Dictionary:
|
|
|
|
|
var query := PhysicsRayQueryParameters2D.create(from, to, collision_mask, [get_rid()])
|
|
|
|
|
return get_world_2d().direct_space_state.intersect_ray(query)
|
|
|
|
|
|
|
|
|
|
func _is_point_free(point: Vector2) -> bool:
|
|
|
|
|
var query := PhysicsPointQueryParameters2D.new()
|
|
|
|
|
query.position = point
|
|
|
|
|
query.collision_mask = collision_mask
|
|
|
|
|
query.exclude = [get_rid()]
|
|
|
|
|
return get_world_2d().direct_space_state.intersect_point(query, 1).is_empty()
|
|
|
|
|
|
2026-10-31 20:32:13 -05:00
|
|
|
# Whether our whole shape fits at this spot.
|
Clean up player.gd: names, comments, grouping, smaller _physics_process
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>
2026-10-31 19:43:17 -05:00
|
|
|
func _is_spot_free(spot: Vector2) -> bool:
|
|
|
|
|
var query := PhysicsShapeQueryParameters2D.new()
|
|
|
|
|
query.shape = collisionShape.shape
|
|
|
|
|
query.transform = Transform2D(0.0, spot)
|
|
|
|
|
query.collision_mask = collision_mask
|
|
|
|
|
query.exclude = [get_rid()]
|
|
|
|
|
return get_world_2d().direct_space_state.intersect_shape(query, 1).is_empty()
|