claw-machine-js
Version:
A physics based claw-machine simulation
28 lines (27 loc) • 1.28 kB
TypeScript
import { IBall } from '../interfaces/Ball.ts';
import { IPosition } from '../interfaces/Position.ts';
/**
* checks if a ball is colliding with a line inside the canvas
* @param ball the current ball
* @param x1 start x point of the line
* @param y1 start y point of the line
* @param x2 end x point of the line
* @param y2 end y point of the line
*/
export declare const isCollidingWithLine: (ball: IBall, x1: number, y1: number, x2: number, y2: number) => boolean;
/**
* Adjusts the position of the ball to correct for penetration by moving it along the normal vector.
*
* @param ball - The ball object to adjust.
* @param normal - The normal vector along which to move the ball.
* @param penetration - The distance to move the ball along the normal vector.
*/
export declare const adjustBallPosition: (ball: IBall, normal: IPosition, penetration: number) => void;
/**
* Handles the response of a ball colliding with a line segment by adjusting the ball's position and velocity.
*
* @param ball - The ball object involved in the collision.
* @param lineStart - The start point of the line segment.
* @param lineEnd - The end point of the line segment.
*/
export declare const collisionResponse: (ball: IBall, lineStart: IPosition, lineEnd: IPosition) => void;