@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
44 lines • 1.51 kB
TypeScript
import { MovementBody, MovementStrategy } from '../MovementStrategy';
/**
* Simulates slippery movement with gradual acceleration and deceleration.
*
* @example
* ```typescript
* const ice = new IceMovement({ x: 1, y: 0 }, 3, 0.25, 0.1);
* movementManager.add(player, ice);
* ```
*/
export declare class IceMovement implements MovementStrategy {
private maxSpeed;
private acceleration;
private friction;
private readonly duration?;
private currentVelocity;
private elapsed;
private stopped;
private readonly targetDirection;
/**
* Creates an ice-like movement behaviour.
*
* @param direction - Initial desired direction (normalized automatically)
* @param maxSpeed - Maximum speed in units per second
* @param acceleration - Fraction of the gap closed per second (0-1)
* @param friction - Fraction of velocity retained per second when stopping (0-1)
* @param duration - Optional duration in seconds
*/
constructor(direction: {
x: number;
y: number;
}, maxSpeed?: number, acceleration?: number, friction?: number, duration?: number | undefined);
update(body: MovementBody, dt: number): void;
isFinished(): boolean;
stop(): void;
resume(): void;
setTargetDirection(direction: {
x: number;
y: number;
}): void;
setParameters(maxSpeed?: number, acceleration?: number, friction?: number): void;
private perSecondFactor;
}
//# sourceMappingURL=IceMovement.d.ts.map