Skip to content

feat(engine): Let a Character Manifest scale its gravity - #1944

Merged
omesser merged 2 commits into
mainfrom
cursor/gravity-scale
Oct 30, 2026
Merged

omesser merged 2 commits into
mainfrom
cursor/gravity-scale

Conversation

@omesser

@omesser omesser commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

What

A Character Manifest can now declare gravity, a multiple of the Engine's default fall (GRAVITY, 3600 pt/s²). The Roster reads it when it builds each Instance. Leave it out and you get 1, which keeps every frame exactly as it is today.

  • GravityScale in fidget-core accepts only 0.25..=2. The manifest boundary rejects 0, negatives, NaN, infinity and non-numbers by name: "gravity" is 0, and must be a number from 0.25 to 2, where 1 is the default fall.
  • Engine::with_gravity_scale sets that Instance's gravity, and Falling uses it.
  • The manifest table in docs/DEVELOPMENT.md documents the field.

Why

Oded wants Characters that don't all fall like a stone: a fish, a bird, something floaty. This is the first slice of #1500. Each Character gets its own gravity. Zero gravity and floating are left for later.

Why 0.25 to 2.

  • Upper bound 2: the top of the slider Support variable gravity #1500 asks for.
  • Lower bound 0.25: at a quarter, a fall takes at most twice as long as today, and a Jump (900 pt/s) peaks 450 pt up, half of a 900-pt laptop display.
  • Near zero: below a quarter the sprite effectively floats, which needs a State of its own, so it belongs to the floating follow-up.
  • Zero is refused, because the sprite would never leave Falling.

Settings override deferred. A global override needs a Settings form, a slider, persistence and a live op to every Engine. That is as big as this slice, so it's tracked separately.

Part of #1500. Follow-ups, filed as sub-issues:

How to test

  • Run cargo test -p fidget-core. The new tests check that a lighter Character lands later and a heavier one sooner, that the same throw goes higher under lighter gravity, that the default scale still falls exactly as main does (the_default_gravity_scale_falls_as_it_always_has: Falling at velocity.y 57.6 on tick 1, Grounded on tick 42), that the Roster gives an Instance its Character's gravity, and that manifests accept and reject the right values.
  • To check by hand, add gravity = 0.5 to a character's character.manifest, run the app, and drag and drop the character. It should fall noticeably slower.

— Cursor agent (P. Coder), on @omesser's behalf.

A manifest may declare gravity = 0.25..2, a multiple of the default fall. Undeclared stays exactly 1. Part of #1500.
@omesser omesser added the enhancement New feature or request label Oct 29, 2026
omesser

This comment was marked as outdated.

@omesser

omesser commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Fix round at d1efb909:

  1. Replaced the_default_gravity_scale_changes_no_frame with the_default_gravity_scale_falls_as_it_always_has. It pins main's numbers for both Engine::new and .with_gravity_scale(GravityScale::DEFAULT): from rest at (100, 0) with 16 ms ticks, tick 1 is Falling with velocity.y == 57.6, and the sprite is Grounded on tick 42. Red checks: self.gravity * dt * 0.999 on the Falling line fails it (57.5424 vs 57.6), and so does GravityScale::DEFAULT = 0.999.
  2. PR body now says character.manifest (the key is a top-level TOML gravity = 0.5).

Also took the note: the JUMP_SPEED doc now says "at default gravity". fidget-core: 658 + 28 pass, pre-commit clean.

— Cursor agent (P. Coder), on @omesser's behalf.

@omesser omesser left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soft+Hard — tip d1efb909 — Cleared

Axis Verdict
Soft Pass
Spec Pass
Hard Pass
Total Cleared

Prior fixes verified

  1. Fixed. the_default_gravity_scale_falls_as_it_always_has now pins main's numbers (first tick Falling with velocity.y == 57.6, Grounded on tick 42) for both Engine::new and with_gravity_scale(GravityScale::DEFAULT). I ran it red against this tip three ways:
    • Falling line self.gravity * dt * 0.999 gives 57.5424, red.
    • Falling line * 1.001 gives 57.6576, red.
    • GRAVITY * scale.get() * 0.999 in with_gravity_scale, red.
  2. Fixed. "How to test" now says character.manifest.

The non-blocking note is done too: the JUMP_SPEED doc now says "at default gravity".

Soft — Pass

The new diff is just the test rewrite and the doc line. The test asserts observable state and velocity, not internals, and it isn't a self-comparison any more. Comments are 3 lines or fewer, there are no sleeps, and there's no string parsing.

Spec — Pass

Unchanged from the last gate. This is the manifest slice of #1500, and zero gravity, the fish, perching and the Settings override stay split out to #1939 to #1942.

Hard — Pass

  • fidget-core on this tip: 658 pass, plus 28 package tests. Nothing outside engine.rs changed since 1dbef15e, so the earlier Node and bin results still stand.
  • CI at review time: build, npm-audit, cargo-audit and trufflehog pass. checks (ubuntu, macOS), windows, renderer and detect-secrets are still pending. CI is reported here, not a merge condition.

Fix list

Fix list empty.

— Cursor agent (subagent of P. Architect), on @omesser's behalf.

@omesser
omesser marked this pull request as ready for review October 29, 2026 16:54

@omesser omesser left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soft CLEARED

Tip: d1efb909

What changed

  • Manifest field: a Character Manifest may declare gravity, a multiple of the default fall from 0.25 to 2. GravityScale refuses anything outside that range, NaN included, and the parser names the bad value.
  • Engine: Engine::with_gravity_scale sets each Instance's gravity, the Roster passes the Character's scale in, and Falling uses it. Undeclared stays at 1.
  • Docs and tests: the manifest table documents the field. New tests cover lighter and heavier falls, a higher throw under light gravity, the default fall pinned to main's numbers, and accepted and rejected manifest values.

What is wrong
Nothing blocking. GRAVITY has no other reader, so no fall or jump path keeps the old constant.

Soft-FIX
None

Non-blocking

  • Field doc: Character::gravity_scale is the only nearby field with no doc comment. One line saying it comes from the manifest's gravity would match its siblings.

Verified: cargo test -p fidget-core passes on the box at this tip, 658 unit tests and 28 integration tests.

— Cursor agent (Architect), on @omesser's behalf.

@omesser omesser added this to the V1 milestone Oct 30, 2026
@omesser omesser added this to Fidget Oct 30, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Fidget Oct 30, 2026
@omesser omesser moved this from Todo to In Progress in Fidget Oct 30, 2026
@omesser
omesser merged commit 54e09b1 into main Oct 30, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Fidget Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant