angry-pixel 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/Animator.d.ts +1 -1
- package/lib/component/AudioPlayer.d.ts +2 -5
- package/lib/component/ComponentTypes.d.ts +1 -0
- package/lib/component/RigidBody.d.ts +8 -25
- package/lib/component/RigidBodyOld.d.ts +39 -0
- package/lib/component/collider/BoxCollider.d.ts +34 -0
- package/lib/component/collider/Collider.d.ts +22 -0
- package/lib/component/collider/PolygonCollider.d.ts +32 -0
- package/lib/component/collider/TilemapCollider.d.ts +16 -0
- package/lib/component/colliderComponent/AbstractColliderComponent.d.ts +15 -10
- package/lib/component/colliderComponent/BoxCollider.d.ts +3 -1
- package/lib/component/colliderComponent/PolygonCollider.d.ts +32 -0
- package/lib/component/colliderComponent/TilemapCollider.d.ts +2 -0
- package/lib/component/colliderComponent/TriangleCollider.d.ts +32 -0
- package/lib/component/rendering/MaskRenderer.d.ts +29 -0
- package/lib/component/rendering/SpriteRenderer.d.ts +46 -0
- package/lib/component/rendering/TextRenderer.d.ts +49 -0
- package/lib/component/rendering/tilemap/CsvTilemapRenderer.d.ts +13 -0
- package/lib/component/rendering/tilemap/Tile.d.ts +7 -0
- package/lib/component/rendering/tilemap/TileData.d.ts +10 -0
- package/lib/component/rendering/tilemap/TiledTilemapRenderer.d.ts +43 -0
- package/lib/component/rendering/tilemap/TilemapRenderer.d.ts +72 -0
- package/lib/component/rendering/tilemap/Tileset.d.ts +25 -0
- package/lib/core/Component.d.ts +25 -25
- package/lib/core/Game.d.ts +0 -8
- package/lib/core/GameObject.d.ts +16 -23
- package/lib/core/Scene.d.ts +10 -8
- package/lib/core/managers/GameObjectManager.d.ts +1 -1
- package/lib/core/managers/IterationManager.d.ts +24 -11
- package/lib/core/managers/SceneManager.d.ts +3 -0
- package/lib/core/managers/TimeManager.d.ts +6 -4
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +12 -12
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/input/GamepadController.d.ts +1 -1
- package/lib/math/Rotation.d.ts +1 -4
- package/lib/physics/PhysicsManager.d.ts +24 -0
- package/lib/physics/PhysicsManagerOld2.d.ts +34 -0
- package/lib/physics/collision/ColliderData.d.ts +15 -0
- package/lib/physics/collision/CollisionManager.d.ts +16 -12
- package/lib/physics/collision/CollisionManagerOld.d.ts +27 -0
- package/lib/physics/collision/QuadTree.d.ts +16 -11
- package/lib/physics/collision/collider/ICollider.d.ts +1 -0
- package/lib/physics/collision/collider/RectangleCollider.d.ts +2 -1
- package/lib/physics/collision/resolver/AABBResolver.d.ts +6 -8
- package/lib/physics/collision/resolver/CollisionResolution.d.ts +6 -0
- package/lib/physics/collision/resolver/CollisionResolver.d.ts +5 -0
- package/lib/physics/collision/resolver/SatResolver.d.ts +7 -6
- package/lib/physics/collision/shape/Polygon.d.ts +31 -0
- package/lib/physics/collision/shape/Rectangle.d.ts +7 -11
- package/lib/physics/collision/shape/Shape.d.ts +13 -24
- package/lib/physics/collision-old/CollisionData.d.ts +8 -0
- package/lib/physics/collision-old/CollisionManager.d.ts +30 -0
- package/lib/physics/collision-old/QuadTree.d.ts +32 -0
- package/lib/physics/collision-old/collider/ICollider.d.ts +14 -0
- package/lib/physics/collision-old/collider/RectangleCollider.d.ts +32 -0
- package/lib/physics/collision-old/resolver/AABBResolver.d.ts +14 -0
- package/lib/physics/collision-old/resolver/ICollisionResolver.d.ts +5 -0
- package/lib/physics/collision-old/resolver/SatResolver.d.ts +14 -0
- package/lib/physics/collision-old/shape/Rectangle.d.ts +13 -0
- package/lib/physics/collision-old/shape/Shape.d.ts +28 -0
- package/lib/physics/rigodBody/RigidBodyData.d.ts +9 -0
- package/lib/physics/rigodBody/RigidBodyManager.d.ts +23 -0
- package/lib/rendering/CullingService.d.ts +0 -1
- package/lib/rendering/context2D/Context2DRenderer.d.ts +0 -1
- package/lib/rendering/renderData/RenderData.d.ts +3 -4
- package/lib/rendering/renderData/TilemapRenderData.d.ts +1 -1
- package/lib/rendering/webGL/renderer/GeometricRenderer.d.ts +3 -5
- package/lib/rendering/webGL/renderer/MaskRenderer.d.ts +1 -1
- package/package.json +1 -1
package/lib/math/Rotation.d.ts
CHANGED
|
@@ -3,10 +3,7 @@ export declare class Rotation {
|
|
|
3
3
|
private _degrees;
|
|
4
4
|
private _radians;
|
|
5
5
|
private _direction;
|
|
6
|
-
constructor(
|
|
7
|
-
radians?: number;
|
|
8
|
-
degrees?: number;
|
|
9
|
-
});
|
|
6
|
+
constructor(radians?: number | null, degrees?: number | null);
|
|
10
7
|
set degrees(degrees: number);
|
|
11
8
|
get degrees(): number;
|
|
12
9
|
set radians(radians: number);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CollisionManager } from "./collision/CollisionManager";
|
|
2
|
+
import { RigidBodyData } from "./rigodBody/RigidBodyData";
|
|
3
|
+
export declare enum RigidBodyType {
|
|
4
|
+
Static = 0,
|
|
5
|
+
Dynamic = 1
|
|
6
|
+
}
|
|
7
|
+
export declare class RigidBodyManager {
|
|
8
|
+
private readonly collisionManager;
|
|
9
|
+
private rigidBodyData;
|
|
10
|
+
private cachePosition;
|
|
11
|
+
private cacheVelocity;
|
|
12
|
+
private cacheGravity;
|
|
13
|
+
private cacheDisplacement;
|
|
14
|
+
private cacheNewDisplacement;
|
|
15
|
+
private cacheCollisions;
|
|
16
|
+
constructor(collisionManager: CollisionManager);
|
|
17
|
+
addRigidBodyData(data: RigidBodyData): void;
|
|
18
|
+
update(deltaTime: number): void;
|
|
19
|
+
private applyGravity;
|
|
20
|
+
private applyVelocity;
|
|
21
|
+
private applyReposition;
|
|
22
|
+
private getCollisions;
|
|
23
|
+
clear(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CollisionManager } from "./collision/CollisionManager";
|
|
2
|
+
import { GameObject } from "../core/GameObject";
|
|
3
|
+
import { Vector2 } from "../math/Vector2";
|
|
4
|
+
import { ICollider } from "./collision/collider/ICollider";
|
|
5
|
+
import { TimeManager } from "../core/managers/TimeManager";
|
|
6
|
+
export declare enum RigidBodyType {
|
|
7
|
+
Static = 0,
|
|
8
|
+
Dynamic = 1
|
|
9
|
+
}
|
|
10
|
+
export interface RigidBodyData {
|
|
11
|
+
gameObject: GameObject;
|
|
12
|
+
gravity: Vector2;
|
|
13
|
+
velocity: Vector2;
|
|
14
|
+
layersToCollider: string[];
|
|
15
|
+
colliders: ICollider[];
|
|
16
|
+
}
|
|
17
|
+
export declare class PhysicsManager {
|
|
18
|
+
private readonly timeManager;
|
|
19
|
+
private readonly collisionManager;
|
|
20
|
+
private rigidBodyData;
|
|
21
|
+
private cachePosition;
|
|
22
|
+
private cacheVelocity;
|
|
23
|
+
private cacheGravity;
|
|
24
|
+
private cacheDisplacement;
|
|
25
|
+
private cacheNewDisplacement;
|
|
26
|
+
constructor(timeManager: TimeManager, collisionManager: CollisionManager);
|
|
27
|
+
addRigidBodyData(data: RigidBodyData): void;
|
|
28
|
+
updatePositions(): void;
|
|
29
|
+
private applyGravityAndVelocity;
|
|
30
|
+
applyReposition(): void;
|
|
31
|
+
private applyRepositionToGameObject;
|
|
32
|
+
private getCollisions;
|
|
33
|
+
clear(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { QuadItem } from "./QuadTree";
|
|
2
|
+
import { Shape } from "./shape/Shape";
|
|
3
|
+
export declare class ColliderData implements QuadItem {
|
|
4
|
+
shape: Shape;
|
|
5
|
+
layer: string;
|
|
6
|
+
id: string;
|
|
7
|
+
updateCollisions: boolean;
|
|
8
|
+
physics: boolean;
|
|
9
|
+
rigidBody: boolean;
|
|
10
|
+
constructor(shape: Shape, layer: string, id: string, updateCollisions: boolean, physics: boolean, rigidBody: boolean);
|
|
11
|
+
get x(): number;
|
|
12
|
+
get y(): number;
|
|
13
|
+
get x1(): number;
|
|
14
|
+
get y1(): number;
|
|
15
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Rectangle } from "../../math/Rectangle";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { ColliderData } from "./ColliderData";
|
|
3
|
+
import { CollisionResolution } from "./resolver/CollisionResolution";
|
|
4
|
+
import { CollisionResolver } from "./resolver/CollisionResolver";
|
|
5
5
|
export interface Collision {
|
|
6
|
-
localCollider:
|
|
7
|
-
remoteCollider:
|
|
8
|
-
|
|
6
|
+
localCollider: ColliderData;
|
|
7
|
+
remoteCollider: ColliderData;
|
|
8
|
+
resolution: CollisionResolution;
|
|
9
9
|
}
|
|
10
10
|
export declare class CollisionManager {
|
|
11
11
|
private colliders;
|
|
@@ -13,15 +13,19 @@ export declare class CollisionManager {
|
|
|
13
13
|
private bounds;
|
|
14
14
|
private fixedQuadTree;
|
|
15
15
|
private resolver;
|
|
16
|
+
private collisions;
|
|
16
17
|
private minBounds;
|
|
17
18
|
private maxBounds;
|
|
18
19
|
private newBounds;
|
|
19
|
-
constructor(resolver:
|
|
20
|
-
addCollider(collider:
|
|
21
|
-
removeCollider(collider:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
constructor(resolver: CollisionResolver, quadTreeBounds: Rectangle | null, quadMaxLevel: number, collidersPerQuad: number);
|
|
21
|
+
addCollider(collider: ColliderData): void;
|
|
22
|
+
removeCollider(collider: ColliderData): void;
|
|
23
|
+
getFrameCollisionsForCollider(collider: ColliderData): Collision[];
|
|
24
|
+
refreshCollisionsForCollider(collider: ColliderData): Collision[];
|
|
25
|
+
clear(): void;
|
|
25
26
|
update(): void;
|
|
26
27
|
private updateNewBounds;
|
|
28
|
+
private updateCollisions;
|
|
29
|
+
private broadPhase;
|
|
30
|
+
private narrowPhase;
|
|
27
31
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Rectangle } from "../../math/Rectangle";
|
|
2
|
+
import { ICollider } from "./collider/ICollider";
|
|
3
|
+
import { CollisionData } from "./CollisionData";
|
|
4
|
+
import { ICollisionResolver } from "./resolver/ICollisionResolver";
|
|
5
|
+
export interface Collision {
|
|
6
|
+
localCollider: ICollider;
|
|
7
|
+
remoteCollider: ICollider;
|
|
8
|
+
collisionData: CollisionData;
|
|
9
|
+
}
|
|
10
|
+
export declare class CollisionManager {
|
|
11
|
+
private colliders;
|
|
12
|
+
private quadTree;
|
|
13
|
+
private bounds;
|
|
14
|
+
private fixedQuadTree;
|
|
15
|
+
private resolver;
|
|
16
|
+
private minBounds;
|
|
17
|
+
private maxBounds;
|
|
18
|
+
private newBounds;
|
|
19
|
+
constructor(resolver: ICollisionResolver, quadTreeBounds: Rectangle | null, quadMaxLevel: number, collidersPerQuad: number);
|
|
20
|
+
addCollider(collider: ICollider): void;
|
|
21
|
+
removeCollider(collider: ICollider): void;
|
|
22
|
+
getCollisionsForCollider(collider: ICollider): Collision[];
|
|
23
|
+
private broadPhase;
|
|
24
|
+
private narrowPhase;
|
|
25
|
+
update(): void;
|
|
26
|
+
private updateNewBounds;
|
|
27
|
+
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Rectangle } from "../../math/Rectangle";
|
|
2
|
-
|
|
3
|
-
export declare const DEFAULT_MAX_COLLIDERS: number;
|
|
2
|
+
export declare const DEFAULT_MAX_ITEMS: number;
|
|
4
3
|
export declare const DEFAULT_MAX_LEVELS: number;
|
|
4
|
+
export interface QuadItem {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
x1: number;
|
|
8
|
+
y1: number;
|
|
9
|
+
}
|
|
5
10
|
export declare class QuadTree {
|
|
6
11
|
private _bounds;
|
|
12
|
+
private _items;
|
|
7
13
|
private _quadrants;
|
|
8
14
|
private readonly maxLevels;
|
|
9
|
-
private readonly
|
|
15
|
+
private readonly maxItems;
|
|
10
16
|
private readonly level;
|
|
11
|
-
private colliders;
|
|
12
17
|
private readonly sw;
|
|
13
18
|
private readonly se;
|
|
14
19
|
private readonly nw;
|
|
@@ -16,17 +21,17 @@ export declare class QuadTree {
|
|
|
16
21
|
private center;
|
|
17
22
|
private childrenWidth;
|
|
18
23
|
private childrenHeight;
|
|
19
|
-
private
|
|
20
|
-
constructor(level: number, bounds: Rectangle, maxLevels?: number,
|
|
24
|
+
private quadsForItem;
|
|
25
|
+
constructor(level: number, bounds: Rectangle, maxLevels?: number, maxItems?: number);
|
|
21
26
|
get bounds(): Rectangle;
|
|
22
27
|
get quadrants(): QuadTree[];
|
|
23
28
|
updateBounds(bounds: Rectangle): void;
|
|
24
|
-
|
|
29
|
+
clearItems(): void;
|
|
25
30
|
clearQuadrants(): void;
|
|
26
|
-
|
|
27
|
-
retrieve(
|
|
31
|
+
addItem(item: QuadItem): void;
|
|
32
|
+
retrieve<T extends QuadItem>(item: QuadItem): T[];
|
|
28
33
|
private splitQuad;
|
|
29
|
-
private
|
|
30
|
-
private
|
|
34
|
+
private getChildrenQuadrantForItem;
|
|
35
|
+
private insertItemIntoChildrenQuads;
|
|
31
36
|
private updateCache;
|
|
32
37
|
}
|
|
@@ -6,6 +6,7 @@ export declare class RectangleCollider implements ICollider {
|
|
|
6
6
|
readonly gameObject: GameObject;
|
|
7
7
|
readonly shape: Rectangle;
|
|
8
8
|
readonly physics: boolean;
|
|
9
|
+
readonly updateCollisions: boolean;
|
|
9
10
|
private _position;
|
|
10
11
|
private _width;
|
|
11
12
|
private _height;
|
|
@@ -13,7 +14,7 @@ export declare class RectangleCollider implements ICollider {
|
|
|
13
14
|
private _quadVertices;
|
|
14
15
|
private _quadMaxBounds;
|
|
15
16
|
private _quadMinBounds;
|
|
16
|
-
constructor(position: Vector2, width: number, height: number, physics: boolean, gameObject: GameObject, angle?: number);
|
|
17
|
+
constructor(position: Vector2, width: number, height: number, physics: boolean, gameObject: GameObject, angle?: number, updateCollisions?: boolean);
|
|
17
18
|
set position(coordinates: Vector2);
|
|
18
19
|
get position(): Vector2;
|
|
19
20
|
set width(width: number);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CollisionResolution } from "./CollisionResolution";
|
|
2
2
|
import { Shape } from "../shape/Shape";
|
|
3
|
-
import {
|
|
4
|
-
export declare class AABBResolver implements
|
|
5
|
-
private shape1Rect;
|
|
6
|
-
private shape2Rect;
|
|
3
|
+
import { CollisionResolver } from "./CollisionResolver";
|
|
4
|
+
export declare class AABBResolver implements CollisionResolver {
|
|
7
5
|
private overlapX;
|
|
8
6
|
private overlapY;
|
|
9
7
|
private minOverlap;
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
private direction;
|
|
9
|
+
private displacementDirection;
|
|
10
|
+
getCollisionResolution(shapeA: Shape, shapeB: Shape): CollisionResolution | null;
|
|
13
11
|
private preventContainment;
|
|
14
12
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Shape } from "../shape/Shape";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class SatResolver implements
|
|
2
|
+
import { CollisionResolution } from "./CollisionResolution";
|
|
3
|
+
import { CollisionResolver } from "./CollisionResolver";
|
|
4
|
+
export declare class SatResolver implements CollisionResolver {
|
|
5
5
|
private axes;
|
|
6
|
-
private
|
|
7
|
-
private
|
|
6
|
+
private projA;
|
|
7
|
+
private projB;
|
|
8
8
|
private currentOverlap;
|
|
9
9
|
private minOverlap;
|
|
10
10
|
private displaceDirection;
|
|
11
|
-
|
|
11
|
+
private direction;
|
|
12
|
+
getCollisionResolution(shapeA: Shape, shapeB: Shape): CollisionResolution | null;
|
|
12
13
|
private projectShapeOntoAxis;
|
|
13
14
|
private preventContainment;
|
|
14
15
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Rectangle } from "../../../math/Rectangle";
|
|
2
|
+
import { Vector2 } from "../../../math/Vector2";
|
|
3
|
+
import { Shape, ShapeType } from "./Shape";
|
|
4
|
+
export declare class Polygon implements Shape {
|
|
5
|
+
protected _type: ShapeType;
|
|
6
|
+
protected _vertices: Vector2[];
|
|
7
|
+
protected _boundingBox: Rectangle;
|
|
8
|
+
protected _projectionAxes: Vector2[];
|
|
9
|
+
protected _position: Vector2;
|
|
10
|
+
protected _angle: number;
|
|
11
|
+
protected _vertexModel: Vector2[];
|
|
12
|
+
private boxMinX;
|
|
13
|
+
private boxMinY;
|
|
14
|
+
private boxMaxX;
|
|
15
|
+
private boxMaxY;
|
|
16
|
+
constructor(vertexModel: Vector2[]);
|
|
17
|
+
get type(): ShapeType;
|
|
18
|
+
get vertices(): Vector2[];
|
|
19
|
+
get boundingBox(): Rectangle;
|
|
20
|
+
get projectionAxes(): Vector2[];
|
|
21
|
+
set position(value: Vector2);
|
|
22
|
+
get position(): Vector2;
|
|
23
|
+
set angle(value: number);
|
|
24
|
+
get angle(): number;
|
|
25
|
+
get vertexModel(): Vector2[];
|
|
26
|
+
set vertexModel(value: Vector2[]);
|
|
27
|
+
update(): void;
|
|
28
|
+
protected updateVertices(): void;
|
|
29
|
+
protected updateBoundingBox(): void;
|
|
30
|
+
protected updateProjectionAxes(): void;
|
|
31
|
+
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { Vector2 } from "../../../math/Vector2";
|
|
2
|
-
import {
|
|
3
|
-
export declare class Rectangle extends
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
private updateDirection;
|
|
10
|
-
private updateAxes;
|
|
11
|
-
clone(): Rectangle;
|
|
12
|
-
getAxes(): Vector2[];
|
|
2
|
+
import { Polygon } from "./Polygon";
|
|
3
|
+
export declare class Rectangle extends Polygon {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
constructor(width: number, height: number, position: Vector2);
|
|
7
|
+
updateSize(width: number, height: number): void;
|
|
8
|
+
protected updateProjectionAxes(): void;
|
|
13
9
|
}
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
+
import { Rectangle } from "../../../math/Rectangle";
|
|
1
2
|
import { Vector2 } from "../../../math/Vector2";
|
|
2
3
|
export declare enum ShapeType {
|
|
3
|
-
|
|
4
|
+
Polygon = 0,
|
|
5
|
+
Circle = 1,
|
|
6
|
+
Line = 2
|
|
4
7
|
}
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
get type(): ShapeType;
|
|
15
|
-
get position(): Vector2;
|
|
16
|
-
set position(position: Vector2);
|
|
17
|
-
get angle(): number;
|
|
18
|
-
set angle(angle: number);
|
|
19
|
-
get width(): number;
|
|
20
|
-
set width(width: number);
|
|
21
|
-
get height(): number;
|
|
22
|
-
set height(height: number);
|
|
23
|
-
get direction(): Vector2;
|
|
24
|
-
get vertices(): Vector2[];
|
|
25
|
-
abstract update(): void;
|
|
26
|
-
abstract clone(): Shape;
|
|
27
|
-
abstract getAxes(): Vector2[];
|
|
8
|
+
export interface Shape {
|
|
9
|
+
readonly vertices: Vector2[];
|
|
10
|
+
readonly type: ShapeType;
|
|
11
|
+
readonly boundingBox: Rectangle;
|
|
12
|
+
readonly projectionAxes: Vector2[];
|
|
13
|
+
vertexModel: Vector2[];
|
|
14
|
+
position: Vector2;
|
|
15
|
+
angle: number;
|
|
16
|
+
update(): void;
|
|
28
17
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Vector2 } from "../../math/Vector2";
|
|
2
|
+
export declare class CollisionData {
|
|
3
|
+
private _penetration;
|
|
4
|
+
private _displacementDirection;
|
|
5
|
+
constructor(penetration: number, displacementDirection: Vector2);
|
|
6
|
+
get penetration(): number;
|
|
7
|
+
get displacementDirection(): Vector2;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Rectangle } from "../../math/Rectangle";
|
|
2
|
+
import { ICollider } from "./collider/ICollider";
|
|
3
|
+
import { CollisionData } from "./CollisionData";
|
|
4
|
+
import { ICollisionResolver } from "./resolver/ICollisionResolver";
|
|
5
|
+
export interface Collision {
|
|
6
|
+
localCollider: ICollider;
|
|
7
|
+
remoteCollider: ICollider;
|
|
8
|
+
collisionData: CollisionData;
|
|
9
|
+
}
|
|
10
|
+
export declare class CollisionManager {
|
|
11
|
+
private colliders;
|
|
12
|
+
private quadTree;
|
|
13
|
+
private bounds;
|
|
14
|
+
private fixedQuadTree;
|
|
15
|
+
private resolver;
|
|
16
|
+
private collisions;
|
|
17
|
+
private minBounds;
|
|
18
|
+
private maxBounds;
|
|
19
|
+
private newBounds;
|
|
20
|
+
constructor(resolver: ICollisionResolver, quadTreeBounds: Rectangle | null, quadMaxLevel: number, collidersPerQuad: number);
|
|
21
|
+
addCollider(collider: ICollider): void;
|
|
22
|
+
removeCollider(collider: ICollider): void;
|
|
23
|
+
getFrameCollisionsForCollider(collider: ICollider): Collision[];
|
|
24
|
+
refreshCollisionsForCollider(collider: ICollider): Collision[];
|
|
25
|
+
update(): void;
|
|
26
|
+
private updateNewBounds;
|
|
27
|
+
private updateCollisions;
|
|
28
|
+
private broadPhase;
|
|
29
|
+
private narrowPhase;
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Rectangle } from "../../math/Rectangle";
|
|
2
|
+
import { ICollider } from "./collider/ICollider";
|
|
3
|
+
export declare const DEFAULT_MAX_COLLIDERS: number;
|
|
4
|
+
export declare const DEFAULT_MAX_LEVELS: number;
|
|
5
|
+
export declare class QuadTree {
|
|
6
|
+
private _bounds;
|
|
7
|
+
private _quadrants;
|
|
8
|
+
private readonly maxLevels;
|
|
9
|
+
private readonly maxColliders;
|
|
10
|
+
private readonly level;
|
|
11
|
+
private colliders;
|
|
12
|
+
private readonly sw;
|
|
13
|
+
private readonly se;
|
|
14
|
+
private readonly nw;
|
|
15
|
+
private readonly ne;
|
|
16
|
+
private center;
|
|
17
|
+
private childrenWidth;
|
|
18
|
+
private childrenHeight;
|
|
19
|
+
private quadrantsForCollider;
|
|
20
|
+
constructor(level: number, bounds: Rectangle, maxLevels?: number, maxColliders?: number);
|
|
21
|
+
get bounds(): Rectangle;
|
|
22
|
+
get quadrants(): QuadTree[];
|
|
23
|
+
updateBounds(bounds: Rectangle): void;
|
|
24
|
+
clearColliders(): void;
|
|
25
|
+
clearQuadrants(): void;
|
|
26
|
+
addCollider(collider: ICollider): void;
|
|
27
|
+
retrieve(collider: ICollider): ICollider[];
|
|
28
|
+
private splitQuad;
|
|
29
|
+
private getChildrenQuadrantForCollider;
|
|
30
|
+
private insertColliderIntoChildrenQuads;
|
|
31
|
+
private updateCache;
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GameObject } from "../../../core/GameObject";
|
|
2
|
+
import { Vector2 } from "../../../math/Vector2";
|
|
3
|
+
import { Shape } from "../shape/Shape";
|
|
4
|
+
export interface ICollider {
|
|
5
|
+
position: Vector2;
|
|
6
|
+
readonly shape: Shape;
|
|
7
|
+
readonly gameObject: GameObject;
|
|
8
|
+
readonly physics: boolean;
|
|
9
|
+
readonly bottomLeftQuadVertex: Vector2;
|
|
10
|
+
readonly bottomRightQuadVertex: Vector2;
|
|
11
|
+
readonly topLeftQuadVertex: Vector2;
|
|
12
|
+
readonly topRightQuadVertex: Vector2;
|
|
13
|
+
readonly updateCollisions: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GameObject } from "../../../core/GameObject";
|
|
2
|
+
import { Vector2 } from "../../../math/Vector2";
|
|
3
|
+
import { Rectangle } from "../shape/Rectangle";
|
|
4
|
+
import { ICollider } from "./ICollider";
|
|
5
|
+
export declare class RectangleCollider implements ICollider {
|
|
6
|
+
readonly gameObject: GameObject;
|
|
7
|
+
readonly shape: Rectangle;
|
|
8
|
+
readonly physics: boolean;
|
|
9
|
+
readonly updateCollisions: boolean;
|
|
10
|
+
private _position;
|
|
11
|
+
private _width;
|
|
12
|
+
private _height;
|
|
13
|
+
private _angle;
|
|
14
|
+
private _quadVertices;
|
|
15
|
+
private _quadMaxBounds;
|
|
16
|
+
private _quadMinBounds;
|
|
17
|
+
constructor(position: Vector2, width: number, height: number, physics: boolean, gameObject: GameObject, angle?: number, updateCollisions?: boolean);
|
|
18
|
+
set position(coordinates: Vector2);
|
|
19
|
+
get position(): Vector2;
|
|
20
|
+
set width(width: number);
|
|
21
|
+
get width(): number;
|
|
22
|
+
set height(height: number);
|
|
23
|
+
get height(): number;
|
|
24
|
+
get angle(): number;
|
|
25
|
+
set angle(angle: number);
|
|
26
|
+
get bottomLeftQuadVertex(): Vector2;
|
|
27
|
+
get bottomRightQuadVertex(): Vector2;
|
|
28
|
+
get topLeftQuadVertex(): Vector2;
|
|
29
|
+
get topRightQuadVertex(): Vector2;
|
|
30
|
+
private updateShape;
|
|
31
|
+
private updateQuadVertices;
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CollisionData } from "../CollisionData";
|
|
2
|
+
import { Shape } from "../shape/Shape";
|
|
3
|
+
import { ICollisionResolver } from "./ICollisionResolver";
|
|
4
|
+
export declare class AABBResolver implements ICollisionResolver {
|
|
5
|
+
private shapeARect;
|
|
6
|
+
private shapeBRect;
|
|
7
|
+
private overlapX;
|
|
8
|
+
private overlapY;
|
|
9
|
+
private minOverlap;
|
|
10
|
+
private displaceDirection;
|
|
11
|
+
getCollisionData(shapeA: Shape, shapeB: Shape): CollisionData | null;
|
|
12
|
+
private setShapeRect;
|
|
13
|
+
private preventContainment;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Shape } from "../shape/Shape";
|
|
2
|
+
import { CollisionData } from "../CollisionData";
|
|
3
|
+
import { ICollisionResolver } from "./ICollisionResolver";
|
|
4
|
+
export declare class SatResolver implements ICollisionResolver {
|
|
5
|
+
private axes;
|
|
6
|
+
private projA;
|
|
7
|
+
private projB;
|
|
8
|
+
private currentOverlap;
|
|
9
|
+
private minOverlap;
|
|
10
|
+
private displaceDirection;
|
|
11
|
+
getCollisionData(shapeA: Shape, shapeB: Shape): CollisionData | null;
|
|
12
|
+
private projectShapeOntoAxis;
|
|
13
|
+
private preventContainment;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Vector2 } from "../../../math/Vector2";
|
|
2
|
+
import { Shape } from "./Shape";
|
|
3
|
+
export declare class Rectangle extends Shape {
|
|
4
|
+
private cacheVector;
|
|
5
|
+
private axes;
|
|
6
|
+
constructor(position: Vector2, width: number, height: number, angle?: number);
|
|
7
|
+
update(): void;
|
|
8
|
+
private updateModel;
|
|
9
|
+
private updateDirection;
|
|
10
|
+
private updateAxes;
|
|
11
|
+
clone(): Rectangle;
|
|
12
|
+
getAxes(): Vector2[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Vector2 } from "../../../math/Vector2";
|
|
2
|
+
export declare enum ShapeType {
|
|
3
|
+
Rectangle = 0
|
|
4
|
+
}
|
|
5
|
+
export declare abstract class Shape {
|
|
6
|
+
protected _type: ShapeType;
|
|
7
|
+
protected _model: Vector2[];
|
|
8
|
+
protected _vertices: Vector2[];
|
|
9
|
+
protected _position: Vector2;
|
|
10
|
+
protected _direction: Vector2;
|
|
11
|
+
protected _height: number;
|
|
12
|
+
protected _width: number;
|
|
13
|
+
protected _angle: number;
|
|
14
|
+
get type(): ShapeType;
|
|
15
|
+
get position(): Vector2;
|
|
16
|
+
set position(position: Vector2);
|
|
17
|
+
get angle(): number;
|
|
18
|
+
set angle(angle: number);
|
|
19
|
+
get width(): number;
|
|
20
|
+
set width(width: number);
|
|
21
|
+
get height(): number;
|
|
22
|
+
set height(height: number);
|
|
23
|
+
get direction(): Vector2;
|
|
24
|
+
get vertices(): Vector2[];
|
|
25
|
+
abstract update(): void;
|
|
26
|
+
abstract clone(): Shape;
|
|
27
|
+
abstract getAxes(): Vector2[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Vector2 } from "../../math/Vector2";
|
|
2
|
+
import { ColliderData } from "../collision/ColliderData";
|
|
3
|
+
export interface RigidBodyData {
|
|
4
|
+
position: Vector2;
|
|
5
|
+
gravity: number;
|
|
6
|
+
velocity: Vector2;
|
|
7
|
+
layersToCollider: string[];
|
|
8
|
+
colliders: ColliderData[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CollisionManager } from "../collision/CollisionManager";
|
|
2
|
+
import { RigidBodyData } from "./RigidBodyData";
|
|
3
|
+
export declare enum RigidBodyType {
|
|
4
|
+
Static = 0,
|
|
5
|
+
Dynamic = 1
|
|
6
|
+
}
|
|
7
|
+
export declare class RigidBodyManager {
|
|
8
|
+
private readonly collisionManager;
|
|
9
|
+
private rigidBodyData;
|
|
10
|
+
private cacheVelocity;
|
|
11
|
+
private cacheDisplacement;
|
|
12
|
+
private cacheNewDisplacement;
|
|
13
|
+
private cacheCollisions;
|
|
14
|
+
constructor(collisionManager: CollisionManager);
|
|
15
|
+
addRigidBodyData(data: RigidBodyData): void;
|
|
16
|
+
removeRigidBodyData(data: RigidBodyData): void;
|
|
17
|
+
update(deltaTime: number): void;
|
|
18
|
+
private applyGravity;
|
|
19
|
+
private applyVelocity;
|
|
20
|
+
private applyReposition;
|
|
21
|
+
private getCollisions;
|
|
22
|
+
clear(): void;
|
|
23
|
+
}
|