Skip to content

[Feature] 2D physics world and configuration #118

@vmarcella

Description

@vmarcella

Overview

Create a 2D physics world that manages rigid bodies, collision detection, and
physics simulation stepping. This is the foundation for all 2D physics.

Current State

No physics support exists in lambda-rs. Games cannot simulate physical
interactions.

Scope

Goals:

  • PhysicsWorld2D type managing the simulation
  • Configurable gravity
  • Fixed timestep integration
  • Builder pattern for world creation

Non-Goals:

  • 3D physics
  • Rigid bodies
  • Collision shapes

Proposed API

// crates/lambda-rs/src/physics/mod.rs
pub struct PhysicsWorld2D {
  // rapier2d pipeline or similar
}

pub struct PhysicsWorld2DBuilder {
  gravity: [f32; 2],
  timestep: f32,
}

impl PhysicsWorld2DBuilder {
  pub fn new() -> Self;
  pub fn with_gravity(self, x: f32, y: f32) -> Self;
  pub fn with_timestep(self, dt: f32) -> Self;

### Acceptance Criteria

- [ ] PhysicsWorld2D can be constructed with builder
- [ ] Gravity is configurable (default 0, -9.81)
- [ ] `step()` advances simulation by fixed timestep
- [ ] World can exist without any bodies
- [ ] Unit tests for world creation and stepping

### Affected Crates

lambda-rs, lambda-rs-platform

### Notes

- Fixed timestep typically 1/60 second
- Consider sub-stepping for stability

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlambda-rsIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappersphysicsAll things related to physics

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions