angry-pixel 1.1.6 → 1.1.8
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/AudioPlayer.d.ts +18 -9
- package/lib/component/RigidBody.d.ts +9 -9
- package/lib/component/collider/BallCollider.d.ts +2 -4
- package/lib/component/collider/BoxCollider.d.ts +2 -4
- package/lib/component/collider/Collider.d.ts +10 -7
- package/lib/component/collider/EdgeCollider.d.ts +2 -4
- package/lib/component/collider/PolygonCollider.d.ts +4 -6
- package/lib/component/collider/TilemapCollider.d.ts +3 -2
- package/lib/core/Component.d.ts +1 -1
- package/lib/core/GameConfig.d.ts +4 -9
- package/lib/core/GameObject.d.ts +1 -1
- package/lib/core/Scene.d.ts +1 -1
- package/lib/core/managers/HeadlessIterationManager.d.ts +4 -4
- package/lib/core/managers/IterationManager.d.ts +4 -4
- package/lib/core/managers/SceneManager.d.ts +1 -3
- package/lib/core/managers/TimeManager.d.ts +1 -1
- package/lib/index.cjs.js +1 -15
- package/lib/index.d.ts +2 -4
- package/lib/index.esm.js +1 -15
- package/lib/index.js +1 -15
- package/lib/utils/Container.d.ts +1 -1
- package/package.json +9 -11
- package/.vscode/settings.json +0 -2
- package/lib/physics/collision/ColliderData.d.ts +0 -15
- package/lib/physics/collision/CollisionManager.d.ts +0 -35
- package/lib/physics/collision/QuadTree.d.ts +0 -37
- package/lib/physics/collision/method/AABBMethod.d.ts +0 -13
- package/lib/physics/collision/method/CollisionMethod.d.ts +0 -5
- package/lib/physics/collision/method/SatMethod.d.ts +0 -11
- package/lib/physics/collision/resolver/AABBResolver.d.ts +0 -11
- package/lib/physics/collision/resolver/CircumferenceAABBResolver.d.ts +0 -9
- package/lib/physics/collision/resolver/CircumferenceResolver.d.ts +0 -7
- package/lib/physics/collision/resolver/CollisionResolver.d.ts +0 -10
- package/lib/physics/collision/resolver/SatResolver.d.ts +0 -17
- package/lib/physics/collision/shape/Circumference.d.ts +0 -17
- package/lib/physics/collision/shape/Line.d.ts +0 -18
- package/lib/physics/collision/shape/Polygon.d.ts +0 -30
- package/lib/physics/collision/shape/Rectangle.d.ts +0 -9
- package/lib/physics/collision/shape/Shape.d.ts +0 -16
- package/lib/physics/rigodBody/RigidBodyData.d.ts +0 -11
- package/lib/physics/rigodBody/RigidBodyManager.d.ts +0 -26
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
import { EngineComponent } from "../core/Component";
|
|
2
2
|
import { InitOptions } from "../core/GameActor";
|
|
3
3
|
export interface AudioPlayerOptions extends InitOptions {
|
|
4
|
-
|
|
4
|
+
audioSource?: HTMLAudioElement;
|
|
5
5
|
volume?: number;
|
|
6
6
|
loop?: boolean;
|
|
7
|
+
playOnStart?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare class AudioPlayer extends EngineComponent {
|
|
9
10
|
readonly allowMultiple: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private
|
|
11
|
+
private audioContext;
|
|
12
|
+
private tracks;
|
|
13
|
+
private _audioSource;
|
|
14
|
+
private _volume;
|
|
15
|
+
private _loop;
|
|
16
|
+
private playOnStart;
|
|
14
17
|
private _playing;
|
|
15
18
|
private _paused;
|
|
16
|
-
protected init(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
protected init({ audioSource, loop, volume, playOnStart }?: AudioPlayerOptions): void;
|
|
20
|
+
protected start(): void;
|
|
21
|
+
set audioSource(audioSource: HTMLAudioElement);
|
|
22
|
+
get audioSource(): HTMLAudioElement;
|
|
23
|
+
set volume(volume: number);
|
|
24
|
+
get volume(): number;
|
|
25
|
+
set loop(loop: boolean);
|
|
26
|
+
get loop(): boolean;
|
|
27
|
+
playClip(audioSource: HTMLAudioElement, volume?: number): void;
|
|
19
28
|
play(): void;
|
|
20
29
|
stop(): void;
|
|
21
30
|
pause(): void;
|
|
22
31
|
private audioEventHandler;
|
|
23
|
-
private
|
|
32
|
+
private userInputEventHandler;
|
|
24
33
|
protected onActiveChange(): void;
|
|
25
34
|
protected onDestroy(): void;
|
|
26
35
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { EngineComponent } from "../core/Component";
|
|
2
2
|
import { Vector2 } from "angry-pixel-math";
|
|
3
|
-
import { RigidBodyType } from "../physics/rigodBody/RigidBodyManager";
|
|
4
3
|
import { InitOptions } from "../core/GameActor";
|
|
5
|
-
|
|
4
|
+
import { RigidBodyType } from "angry-pixel-2d-physics";
|
|
5
|
+
export { RigidBodyType } from "angry-pixel-2d-physics";
|
|
6
6
|
export interface RigidBodyOptions extends InitOptions {
|
|
7
7
|
rigidBodyType: RigidBodyType;
|
|
8
8
|
gravity?: number;
|
|
9
9
|
}
|
|
10
10
|
export declare class RigidBody extends EngineComponent {
|
|
11
11
|
readonly allowMultiple: boolean;
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
set velocity(velocity: Vector2);
|
|
12
|
+
private physicsManager;
|
|
13
|
+
private rigidBody;
|
|
15
14
|
get velocity(): Vector2;
|
|
16
|
-
set
|
|
15
|
+
set velocity(velocity: Vector2);
|
|
17
16
|
get gravity(): number;
|
|
18
|
-
|
|
17
|
+
set gravity(gravity: number);
|
|
19
18
|
protected init({ rigidBodyType, gravity }: RigidBodyOptions): void;
|
|
20
|
-
protected start(): void;
|
|
21
19
|
protected update(): void;
|
|
22
|
-
private
|
|
20
|
+
private getColliderIds;
|
|
21
|
+
protected onActiveChange(): void;
|
|
22
|
+
protected onDestroy(): void;
|
|
23
23
|
}
|
|
@@ -18,10 +18,8 @@ export declare class BallCollider extends Collider {
|
|
|
18
18
|
private realPosition;
|
|
19
19
|
private innerPosition;
|
|
20
20
|
protected init(config: BallColliderOptions): void;
|
|
21
|
-
protected
|
|
22
|
-
protected update(): void;
|
|
23
|
-
private updateRealSize;
|
|
21
|
+
protected updateRealSize(): void;
|
|
24
22
|
protected updatePosition(): void;
|
|
25
23
|
private translate;
|
|
26
|
-
|
|
24
|
+
protected updateColliders(): void;
|
|
27
25
|
}
|
|
@@ -26,10 +26,8 @@ export declare class BoxCollider extends Collider {
|
|
|
26
26
|
private applyRotation;
|
|
27
27
|
private innerPosition;
|
|
28
28
|
protected init(config: BoxColliderOptions): void;
|
|
29
|
-
protected
|
|
30
|
-
protected update(): void;
|
|
31
|
-
private updateRealSize;
|
|
29
|
+
protected updateRealSize(): void;
|
|
32
30
|
protected updatePosition(): void;
|
|
33
31
|
private translate;
|
|
34
|
-
|
|
32
|
+
protected updateColliders(): void;
|
|
35
33
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ColliderComponent, RenderComponent } from "../../core/Component";
|
|
2
|
-
import { CollisionManager } from "../../physics/collision/CollisionManager";
|
|
3
|
-
import { ColliderData } from "../../physics/collision/ColliderData";
|
|
4
2
|
import { GameObject } from "../../core/GameObject";
|
|
5
|
-
import {
|
|
3
|
+
import { ICollisionResolution, ICollider, IPhysicsManager } from "angry-pixel-2d-physics";
|
|
6
4
|
export interface CollisionData {
|
|
7
|
-
resolution:
|
|
8
|
-
collider:
|
|
5
|
+
resolution: ICollisionResolution;
|
|
6
|
+
collider: ICollider;
|
|
9
7
|
gameObject: GameObject;
|
|
10
8
|
/**
|
|
11
9
|
* @return The GameObject to which this component belongs
|
|
@@ -13,15 +11,20 @@ export interface CollisionData {
|
|
|
13
11
|
getGameObject: <T extends GameObject>() => T;
|
|
14
12
|
}
|
|
15
13
|
export declare abstract class Collider extends ColliderComponent {
|
|
16
|
-
protected
|
|
14
|
+
protected physicsManager: IPhysicsManager;
|
|
17
15
|
protected renderer: RenderComponent;
|
|
18
|
-
readonly colliders:
|
|
16
|
+
readonly colliders: ICollider[];
|
|
19
17
|
layer: string;
|
|
20
18
|
physics: boolean;
|
|
19
|
+
private activateColliders;
|
|
20
|
+
protected abstract updateRealSize(): void;
|
|
21
|
+
protected abstract updatePosition(): void;
|
|
22
|
+
protected abstract updateColliders(): void;
|
|
21
23
|
protected update(): void;
|
|
22
24
|
collidesWithLayer(layer: string): boolean;
|
|
23
25
|
getCollisionWithLayer(layer: string): CollisionData | null;
|
|
24
26
|
getCollisionsWithLayer(layer: string): CollisionData[];
|
|
25
27
|
private createCollisionData;
|
|
26
28
|
protected onActiveChange(): void;
|
|
29
|
+
protected onDestroy(): void;
|
|
27
30
|
}
|
|
@@ -22,10 +22,8 @@ export declare class EdgeCollider extends Collider {
|
|
|
22
22
|
private finalRotation;
|
|
23
23
|
private innerPosition;
|
|
24
24
|
protected init(config: EdgeColliderOptions): void;
|
|
25
|
-
protected
|
|
26
|
-
protected update(): void;
|
|
27
|
-
private updateSize;
|
|
25
|
+
protected updateRealSize(): void;
|
|
28
26
|
protected updatePosition(): void;
|
|
29
27
|
private translate;
|
|
30
|
-
|
|
28
|
+
protected updateColliders(): void;
|
|
31
29
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Collider } from "./Collider";
|
|
2
|
-
import { ColliderData } from "../../physics/collision/ColliderData";
|
|
3
2
|
import { RenderComponent } from "../../core/Component";
|
|
4
3
|
import { InitOptions } from "../../core/GameActor";
|
|
5
4
|
import { Vector2, Rotation } from "angry-pixel-math";
|
|
5
|
+
import { ICollider } from "angry-pixel-2d-physics";
|
|
6
6
|
export interface PolygonColliderOptions extends InitOptions {
|
|
7
7
|
vertexModel: Vector2[];
|
|
8
8
|
offsetX?: number;
|
|
@@ -24,19 +24,17 @@ export declare class PolygonCollider extends Collider {
|
|
|
24
24
|
private finalRotation;
|
|
25
25
|
private innerPosition;
|
|
26
26
|
protected init(config: PolygonColliderOptions): void;
|
|
27
|
-
protected
|
|
28
|
-
protected update(): void;
|
|
29
|
-
private updateSize;
|
|
27
|
+
protected updateRealSize(): void;
|
|
30
28
|
protected updatePosition(): void;
|
|
31
29
|
private translate;
|
|
32
|
-
|
|
30
|
+
protected updateColliders(): void;
|
|
33
31
|
}
|
|
34
32
|
export declare class PolygonColliderRenderer extends RenderComponent {
|
|
35
33
|
private renderManager;
|
|
36
34
|
private renderData;
|
|
37
35
|
private collider;
|
|
38
36
|
protected init({ collider }: {
|
|
39
|
-
collider:
|
|
37
|
+
collider: ICollider;
|
|
40
38
|
}): void;
|
|
41
39
|
protected update(): void;
|
|
42
40
|
}
|
|
@@ -17,12 +17,13 @@ export declare class TilemapCollider extends Collider {
|
|
|
17
17
|
private scaledTileHeight;
|
|
18
18
|
private position;
|
|
19
19
|
protected init(config: TilemapColliderOptions): void;
|
|
20
|
-
protected start(): void;
|
|
21
20
|
private useBoxColliders;
|
|
22
21
|
private useLineColliders;
|
|
23
22
|
private hasTile;
|
|
24
23
|
private addLineCollider;
|
|
25
24
|
private needsCollider;
|
|
26
25
|
private getNeighbors;
|
|
27
|
-
protected
|
|
26
|
+
protected updateRealSize(): void;
|
|
27
|
+
protected updatePosition(): void;
|
|
28
|
+
protected updateColliders(): void;
|
|
28
29
|
}
|
package/lib/core/Component.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Scene } from "./Scene";
|
|
|
3
3
|
import { FrameEvent } from "./managers/IterationManager";
|
|
4
4
|
import { GameActor } from "./GameActor";
|
|
5
5
|
import { Container } from "../utils/Container";
|
|
6
|
-
export
|
|
6
|
+
export type ComponentClass<T extends Component = Component> = new (container: Container, gameObject: GameObject, name?: string) => T;
|
|
7
7
|
export declare abstract class Component extends GameActor {
|
|
8
8
|
readonly id: string;
|
|
9
9
|
readonly name: string;
|
package/lib/core/GameConfig.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
+
import { BroadPhaseMethods, CollisionMatrix, CollisionMethods } from "angry-pixel-2d-physics";
|
|
1
2
|
import { Rectangle, Vector2 } from "angry-pixel-math";
|
|
2
|
-
import { CollisionMatrix } from "../physics/collision/CollisionManager";
|
|
3
|
-
export declare enum CollisionMethodConfig {
|
|
4
|
-
AABB = "aabb",
|
|
5
|
-
SAT = "sat"
|
|
6
|
-
}
|
|
7
3
|
export interface GameConfig {
|
|
8
4
|
containerNode?: HTMLElement | null;
|
|
9
5
|
gameWidth?: number;
|
|
@@ -14,10 +10,9 @@ export interface GameConfig {
|
|
|
14
10
|
spriteDefaultScale?: Vector2 | null;
|
|
15
11
|
headless?: boolean;
|
|
16
12
|
collisions?: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
quadMaxLevel?: number;
|
|
20
|
-
collidersPerQuad?: number;
|
|
13
|
+
collisionMethod?: CollisionMethods;
|
|
14
|
+
collisionArea?: Rectangle;
|
|
21
15
|
collisionMatrix?: CollisionMatrix;
|
|
16
|
+
collisionBroadPhaseMethod?: BroadPhaseMethods;
|
|
22
17
|
};
|
|
23
18
|
}
|
package/lib/core/GameObject.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Scene } from "./Scene";
|
|
|
5
5
|
import { GameActor, InitOptions } from "./GameActor";
|
|
6
6
|
import { Container } from "../utils/Container";
|
|
7
7
|
export declare const LAYER_DEFAULT = "Default";
|
|
8
|
-
export
|
|
8
|
+
export type GameObjectClass<T extends GameObject = GameObject> = new (container: Container, name?: string, parent?: GameObject) => T;
|
|
9
9
|
export declare class GameObject extends GameActor {
|
|
10
10
|
readonly id: string;
|
|
11
11
|
readonly name: string;
|
package/lib/core/Scene.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { GameCamera } from "../gameObject/GameCamera";
|
|
|
2
2
|
import { Container } from "../utils/Container";
|
|
3
3
|
import { Game } from "./Game";
|
|
4
4
|
import { GameActor } from "./GameActor";
|
|
5
|
-
export
|
|
5
|
+
export type SceneClass = new (container: Container, name: string, game: Game) => Scene;
|
|
6
6
|
export declare class Scene extends GameActor {
|
|
7
7
|
readonly name: string;
|
|
8
8
|
readonly game: Game;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { GameObjectManager } from "./GameObjectManager";
|
|
2
2
|
import { SceneManager } from "./SceneManager";
|
|
3
|
-
import { CollisionManager } from "../../physics/collision/CollisionManager";
|
|
4
|
-
import { RigidBodyManager } from "../../physics/rigodBody/RigidBodyManager";
|
|
5
3
|
import { TimeManager } from "./TimeManager";
|
|
6
4
|
import { IIterationManager } from "./IterationManager";
|
|
5
|
+
import { IPhysicsManager } from "angry-pixel-2d-physics";
|
|
7
6
|
export declare class HeadlessIterationManager implements IIterationManager {
|
|
8
7
|
private readonly timeManager;
|
|
9
|
-
private readonly collisionManager;
|
|
10
8
|
private readonly physicsManager;
|
|
11
9
|
private readonly gameObjectManager;
|
|
12
10
|
private readonly sceneManager;
|
|
@@ -14,7 +12,9 @@ export declare class HeadlessIterationManager implements IIterationManager {
|
|
|
14
12
|
private currentScene;
|
|
15
13
|
private gameObjects;
|
|
16
14
|
private components;
|
|
17
|
-
|
|
15
|
+
private gameInterval;
|
|
16
|
+
private physicsInterval;
|
|
17
|
+
constructor(timeManager: TimeManager, physicsManager: IPhysicsManager, gameObjectManager: GameObjectManager, sceneManager: SceneManager);
|
|
18
18
|
start(): void;
|
|
19
19
|
pause(): void;
|
|
20
20
|
resume(): void;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { GameObjectManager } from "./GameObjectManager";
|
|
2
2
|
import { SceneManager } from "./SceneManager";
|
|
3
3
|
import { InputManager } from "../../input/InputManager";
|
|
4
|
-
import { CollisionManager } from "../../physics/collision/CollisionManager";
|
|
5
|
-
import { RigidBodyManager } from "../../physics/rigodBody/RigidBodyManager";
|
|
6
4
|
import { IRenderManager } from "angry-pixel-2d-renderer";
|
|
7
5
|
import { TimeManager } from "./TimeManager";
|
|
6
|
+
import { IPhysicsManager } from "angry-pixel-2d-physics";
|
|
8
7
|
export declare enum FrameEvent {
|
|
9
8
|
Init = 0,
|
|
10
9
|
Start = 1,
|
|
@@ -25,9 +24,9 @@ export interface IIterationManager {
|
|
|
25
24
|
resume(): void;
|
|
26
25
|
stop(): void;
|
|
27
26
|
}
|
|
27
|
+
export declare const now: () => number;
|
|
28
28
|
export declare class IterationManager implements IIterationManager {
|
|
29
29
|
private readonly timeManager;
|
|
30
|
-
private readonly collisionManager;
|
|
31
30
|
private readonly physicsManager;
|
|
32
31
|
private readonly renderManager;
|
|
33
32
|
private readonly inputManager;
|
|
@@ -39,7 +38,8 @@ export declare class IterationManager implements IIterationManager {
|
|
|
39
38
|
private currentScene;
|
|
40
39
|
private gameObjects;
|
|
41
40
|
private components;
|
|
42
|
-
|
|
41
|
+
private physicsIntervalId;
|
|
42
|
+
constructor(timeManager: TimeManager, physicsManager: IPhysicsManager, renderManager: IRenderManager, inputManager: InputManager, gameObjectManager: GameObjectManager, sceneManager: SceneManager, canvasColor: string);
|
|
43
43
|
start(): void;
|
|
44
44
|
pause(): void;
|
|
45
45
|
resume(): void;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { Game } from "../Game";
|
|
2
1
|
import { Scene, SceneClass } from "../Scene";
|
|
3
2
|
import { IRenderManager } from "angry-pixel-2d-renderer";
|
|
4
3
|
import { InitOptions } from "../GameActor";
|
|
5
4
|
import { Container } from "../../utils/Container";
|
|
6
5
|
export declare class SceneManager {
|
|
7
6
|
private readonly container;
|
|
8
|
-
private game;
|
|
9
7
|
private renderManager?;
|
|
10
8
|
private scenes;
|
|
11
9
|
private currentScene;
|
|
12
10
|
private openingSceneName;
|
|
13
11
|
private sceneToLoad;
|
|
14
12
|
currentSceneName: string;
|
|
15
|
-
constructor(container: Container,
|
|
13
|
+
constructor(container: Container, renderManager?: IRenderManager);
|
|
16
14
|
getCurrentScene<T extends Scene>(): T;
|
|
17
15
|
addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
|
|
18
16
|
loadOpeningScene(): void;
|