claw-machine-js
Version:
A physics based claw-machine simulation
66 lines (65 loc) • 4.16 kB
TypeScript
import { IBall } from '../interfaces/Ball.ts';
import { IPosition } from '../interfaces/Position.ts';
/**
* checks weather the ball has collided with the left inner claw. And handle the collision (push it inside)
* @param ball the current ball
* @param leftLineStart start point of the left inner claw
* @param leftLineMiddle1 upper mid-point of the left inner claw
* @param leftLineMiddle2 lower mid-point of the left inner claw
* @param leftLineEnd end point of the left inner claw
* @param shouldReturnOnContact should the claw retract if a ball is touched
* @param handleBallTouched function that gets called if the claw touches a ball
*/
export declare function calculateCollisionWithLeftInnerClaw(ball: IBall, leftLineStart: IPosition, leftLineMiddle1: IPosition, leftLineMiddle2: IPosition, leftLineEnd: IPosition, shouldReturnOnContact: boolean, handleBallTouched: () => void): void;
/**
* checks weather the ball has collided with the right inner claw. And handle the collision (push it inside)
* @param ball the current ball
* @param rightLineStart start point of the right inner claw
* @param rightLineMiddle1 upper mid-point of the right inner claw
* @param rightLineMiddle2 lower mid-point of the right inner claw
* @param rightLineEnd end point of the right inner claw
* @param shouldReturnOnContact should the claw retract if a ball is touched
* @param handleBallTouched function that gets called if the claw touches a ball
*/
export declare function calculateCollisionWithRightInnerClaw(ball: IBall, rightLineStart: IPosition, rightLineMiddle1: IPosition, rightLineMiddle2: IPosition, rightLineEnd: IPosition, shouldReturnOnContact: boolean, handleBallTouched: () => void): void;
/**
* checks weather the ball has collided with the right outer claw. And handle the collision (push it outside)
* @param ball the current ball
* @param rightOuterLineStart start point of the right outer claw
* @param rightOuterLineMiddle1 upper mid-point of the right outer claw
* @param rightOuterLineMiddle2 lower mid-point of the right outer claw
* @param rightOuterLineEnd end point of the right outer claw
*/
export declare function calculateCollisionWithRightOuterClaw(ball: IBall, rightOuterLineStart: IPosition, rightOuterLineMiddle1: IPosition, rightOuterLineMiddle2: IPosition, rightOuterLineEnd: IPosition): void;
/**
* checks weather the ball has collided with the left outer claw. And handle the collision (push it outside)
* @param ball the current ball
* @param leftOuterLineStart start point of the left outer claw
* @param leftOuterLineMiddle1 upper mid-point of the left outer claw
* @param leftOuterLineMiddle2 lower mid-point of the left outer claw
* @param leftOuterLineEnd end point of the left outer claw
*/
export declare function calculateCollisionWithLeftOuterClaw(ball: IBall, leftOuterLineStart: IPosition, leftOuterLineMiddle1: IPosition, leftOuterLineMiddle2: IPosition, leftOuterLineEnd: IPosition): void;
/**
* calculates the collision with the divider line in the middle of the canvas
* @param ball the current ball
* @param dividerLineLeftStart start point of the left divider Line
* @param dividerLineLeftEnd end point of the left divider Line
* @param dividerLineRightStart start point of the right divider Line
* @param dividerLineRightEnd end point of the right divider Line
*/
export declare function calculateCollisionWithDividerLines(ball: IBall, dividerLineLeftStart: IPosition, dividerLineLeftEnd: IPosition, dividerLineRightStart: IPosition, dividerLineRightEnd: IPosition): void;
/**
* calculates the collision with the canvas edges
* @param ball current ball
* @param width width of the canvas
* @param height height of the canvas
* @param friction friction of the canvas edges
* @param groundFriction friction of the canvas ground
*/
export declare function calculateCollisionWithCanvasEdges(ball: IBall, width: number, height: number, friction: number, groundFriction: number): void;
/**
* calculates the collision between all the balls
* @param balls list of the balls inside the canvas
*/
export declare function calculateCollisionsBetweenBalls(balls: IBall[]): void;