Skip to content

RigidActor

A body fully simulated by the physics engine.

Description

Rigid actors respond to gravity, forces, and impulses. They are used for dynamic objects that should behave naturally, like falling crates or debris.

Namespace

namespace pixelroot32::physics {
    class RigidActor {
        // ...
    };
}

Inheritance

Constructors

  • RigidActor(Scalar x, Scalar y, int w, int h) Constructs a new RigidActor.

  • RigidActor(Vector2 position, int w, int h) Constructs a new RigidActor using a position vector.

Public Methods

  • void applyForce(const Vector2& f) Applies a force to the center of mass.

  • void applyImpulse(const Vector2& j) Applies an instantaneous impulse (velocity change).

  • void integrate(Scalar dt) Integrates forces to update velocity. Note: Position integration is handled automatically by CollisionSystem after this step.

  • void update(unsigned long deltaTime) Logic update called every frame. Only integrates velocity/forces. Position update is delegated to CollisionSystem.

  • void draw(pixelroot32::graphics::Renderer& renderer) Draws the actor.

Example

auto box = std::make_unique<RigidActor>(100, 0, 16, 16);
box->setRestitution(0.5f); // Bounciness
scene->addEntity(box.get());