@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
31 lines • 1.04 kB
TypeScript
import { MovementBody, MovementStrategy } from '../MovementStrategy';
/**
* Simulates an impulse that pushes an entity away and gradually decays.
*
* @example
* ```typescript
* movementManager.add(enemy, new Knockback({ x: -1, y: 0 }, 12, 0.25, 0.4));
* ```
*/
export declare class Knockback implements MovementStrategy {
private readonly duration;
private readonly decayFactor;
private readonly direction;
private elapsed;
private currentSpeed;
/**
* Creates a knockback movement.
*
* @param direction - Direction of the impulse (will be normalized)
* @param initialSpeed - Initial speed in units per second
* @param duration - Duration in seconds
* @param decayFactor - Fraction of speed preserved per second (0-1)
*/
constructor(direction: {
x: number;
y: number;
}, initialSpeed: number, duration: number, decayFactor?: number);
update(body: MovementBody, dt: number): void;
isFinished(): boolean;
}
//# sourceMappingURL=Knockback.d.ts.map