UNPKG

@rpgjs/physic

Version:

A deterministic 2D top-down physics library for RPG, sandbox and MMO games

91 lines 3 kB
import { Vector2 } from '../core/math/Vector2'; import { Entity } from './Entity'; /** * Force system for applying various types of forces to entities * * Provides utilities for common force patterns in top-down physics. */ /** * Applies a constant force (e.g., wind, magnetic field) * * @param entity - Entity to apply force to * @param force - Force vector * * @example * ```typescript * applyConstantForce(entity, new Vector2(5, 0)); // Wind pushing right * ``` */ export declare function applyConstantForce(entity: Entity, force: Vector2): void; /** * Applies an attraction force towards a point * * @param entity - Entity to apply force to * @param target - Target point * @param strength - Force strength * @param maxDistance - Maximum distance for force application (optional) * * @example * ```typescript * applyAttraction(entity, new Vector2(0, 0), 10); // Attract to origin * ``` */ export declare function applyAttraction(entity: Entity, target: Vector2, strength: number, maxDistance?: number): void; /** * Applies a repulsion force from a point * * @param entity - Entity to apply force to * @param source - Source point to repel from * @param strength - Force strength * @param maxDistance - Maximum distance for force application (optional) * * @example * ```typescript * applyRepulsion(entity, new Vector2(0, 0), 10); // Repel from origin * ``` */ export declare function applyRepulsion(entity: Entity, source: Vector2, strength: number, maxDistance?: number): void; /** * Applies a directional force field * * @param entity - Entity to apply force to * @param direction - Direction of the force field * @param strength - Force strength * * @example * ```typescript * applyDirectionalForce(entity, new Vector2(1, 0), 5); // Push right * ``` */ export declare function applyDirectionalForce(entity: Entity, direction: Vector2, strength: number): void; /** * Applies an explosion force (radial impulse) * * @param entity - Entity to apply force to * @param center - Explosion center * @param strength - Explosion strength * @param radius - Explosion radius * @param falloff - Distance falloff factor (default: 1, linear) * * @example * ```typescript * applyExplosion(entity, new Vector2(0, 0), 100, 50); // Explosion at origin * ``` */ export declare function applyExplosion(entity: Entity, center: Vector2, strength: number, radius: number, falloff?: number): void; /** * Applies a spring force between two entities * * @param entityA - First entity * @param entityB - Second entity * @param restLength - Rest length of the spring * @param springConstant - Spring constant (stiffness) * @param damping - Damping coefficient * * @example * ```typescript * applySpring(entity1, entity2, 10, 0.5, 0.1); // Spring between entities * ``` */ export declare function applySpring(entityA: Entity, entityB: Entity, restLength: number, springConstant: number, damping: number): void; //# sourceMappingURL=forces.d.ts.map