Add gravity/drop physics to items #15

Merged
scruffydude merged 1 commit from task/14-drop-physics into main 2026-10-01 23:17:23 -04:00
Owner

Items are now RigidBody2D instead of plain Node2D, with a new floor collider (Ground StaticBody2D) so dropped items fall under gravity and settle with a small bounce instead of freezing wherever the mouse released them.

Click detection is unchanged (still manual _unhandled_input + _contains_point from #12) — physics is purely for the fall/settle feel, not a second input path.

_start_drag() freezes the item (kinematic-style, so direct mouse-follow positioning doesn't fight gravity); _try_snap() keeps it frozen on a successful placement or unfreezes it on a miss so it falls and settles. Items only collide with the floor (layer 2 / mask 1), not each other — that's separate scope.

Verified headlessly (physics simulation runs fully without a display, unlike mouse position): gravity pulls an unfrozen item down and it settles on the floor within a few seconds without perpetual jitter; a frozen/dragged item doesn't move despite many physics frames; placing onto the correct stand freezes it permanently; full #3/#4 regression suite still passes.

Closes #14

Items are now `RigidBody2D` instead of plain `Node2D`, with a new floor collider (`Ground` StaticBody2D) so dropped items fall under gravity and settle with a small bounce instead of freezing wherever the mouse released them. Click detection is unchanged (still manual `_unhandled_input` + `_contains_point` from #12) — physics is purely for the fall/settle feel, not a second input path. `_start_drag()` freezes the item (kinematic-style, so direct mouse-follow positioning doesn't fight gravity); `_try_snap()` keeps it frozen on a successful placement or unfreezes it on a miss so it falls and settles. Items only collide with the floor (layer 2 / mask 1), not each other — that's separate scope. Verified headlessly (physics simulation runs fully without a display, unlike mouse position): gravity pulls an unfrozen item down and it settles on the floor within a few seconds without perpetual jitter; a frozen/dragged item doesn't move despite many physics frames; placing onto the correct stand freezes it permanently; full #3/#4 regression suite still passes. Closes #14
Items are now RigidBody2D instead of plain Node2D. A floor collider
(Ground StaticBody2D) was added so dropped items fall under gravity
and settle on it with a small bounce, instead of just freezing in
mid-air wherever the mouse released them.

Click detection is untouched (still manual _unhandled_input +
_contains_point, per #12) - the RigidBody2D only adds real physics
simulation, not a second, physics-based input path.

Drag/placement integration:
- _start_drag() sets freeze = true so the item behaves kinematically
  while the mouse moves it directly (gravity doesn't fight the drag).
- _try_snap() keeps it frozen in place on a successful placement, or
  sets freeze = false on a miss so it falls and settles where dropped.

Items collide only with the floor (collision_layer 2, mask 1), not
with each other - that's separate scope per #14.

Verified headlessly (physics simulation runs fully in headless mode,
unlike mouse position - see memory notes):
- An unfrozen item falls under gravity and settles on the floor
  within a few seconds, then stays put (no perpetual sinking/jitter).
- A frozen/dragged item does not move at all despite many physics
  frames passing.
- Dropping onto the correct stand freezes it there permanently.
- Full #3/#4 snap-to-stand and win-condition regression suite still
  passes with the RigidBody2D conversion.

Closes #14

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
scruffydude/project-awry!15
No description provided.