@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
35 lines • 1.22 kB
TypeScript
import { MovementBody, MovementStrategy } from '../MovementStrategy';
/**
* Oscillates an entity around its initial position using different wave patterns.
*
* @example
* ```typescript
* movementManager.add(platform, new Oscillate({ x: 1, y: 0 }, 2, 3, 'sine'));
* ```
*/
export declare class Oscillate implements MovementStrategy {
private readonly amplitude;
private readonly period;
private readonly type;
private readonly duration?;
private readonly direction;
private elapsed;
private anchor;
/**
* Creates an oscillating movement.
*
* @param direction - Base direction (will be normalized)
* @param amplitude - Maximum displacement from the anchor position
* @param period - Duration of a full cycle in seconds
* @param type - Oscillation pattern
* @param duration - Total life time in seconds (undefined for infinite)
*/
constructor(direction: {
x: number;
y: number;
}, amplitude: number, period: number, type?: 'linear' | 'sine' | 'circular', duration?: number | undefined);
update(body: MovementBody, dt: number): void;
isFinished(): boolean;
reset(): void;
}
//# sourceMappingURL=Oscillate.d.ts.map