angry-pixel 1.1.2 → 1.1.3

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.
@@ -10,10 +10,13 @@ export declare class Animator extends EngineComponent {
10
10
  private spriteRenderer;
11
11
  private animations;
12
12
  private currentAnimation;
13
+ private paused;
13
14
  protected init({ spriteRenderer }: AnimatorOptions): void;
14
15
  protected update(): void;
15
- addAnimation(name: string, animation: Animation, framerate?: number): this;
16
- playAnimation(name: string): void;
16
+ addAnimation(animation: Animation, name?: string, framerate?: number): this;
17
+ playAnimation(name?: string): void;
18
+ pause(): void;
19
+ resume(): void;
17
20
  stopAnimation(): void;
18
21
  isPlayingAnimation(name: string): boolean;
19
22
  }
@@ -0,0 +1,42 @@
1
+ import { Component } from "../core/Component";
2
+ import { InitOptions } from "../core/GameActor";
3
+ import { Vector2 } from "../math/Vector2";
4
+ export declare enum ButtonType {
5
+ Rectangle = 0,
6
+ Circumference = 1
7
+ }
8
+ export interface ButtonOptions extends InitOptions {
9
+ type: ButtonType;
10
+ width?: number;
11
+ height?: number;
12
+ radius?: number;
13
+ touchEnabled?: boolean;
14
+ offset?: Vector2;
15
+ }
16
+ export declare class Button extends Component {
17
+ readonly allowMultiple: boolean;
18
+ type: ButtonType;
19
+ width: number;
20
+ height: number;
21
+ radius: number;
22
+ touchEnabled: boolean;
23
+ private _offset;
24
+ pressed: boolean;
25
+ private mouse;
26
+ private touch;
27
+ private position;
28
+ private distance;
29
+ private pressedLastFrame;
30
+ private scaled;
31
+ onClick: () => void;
32
+ onPressed: () => void;
33
+ get offset(): Vector2;
34
+ set offset(offset: Vector2);
35
+ protected init({ type, height, radius, touchEnabled, width, offset }: ButtonOptions): void;
36
+ protected update(): void;
37
+ private scale;
38
+ protected resolveMouseAndRectangle(): void;
39
+ protected resolveMouseAndCircumference(): void;
40
+ protected resolveTouchAndRectangle(): void;
41
+ protected resolveTouchAndCircumference(): void;
42
+ }
@@ -23,6 +23,7 @@ export declare class Transform extends TransformComponent {
23
23
  get innerPosition(): Vector2;
24
24
  set innerPosition(innerPosition: Vector2);
25
25
  get parent(): Transform | null;
26
+ set parent(parent: Transform | null);
26
27
  protected update(): void;
27
28
  private setParent;
28
29
  private setPositionFromParent;
@@ -1,10 +1,13 @@
1
1
  import { Vector2 } from "../../../math/Vector2";
2
2
  export declare class TileData {
3
- private _position;
4
- private _width;
5
- private _height;
3
+ readonly position: Vector2;
4
+ readonly width: number;
5
+ readonly height: number;
6
+ private readonly halfWidth;
7
+ private readonly halfHeight;
6
8
  constructor(position: Vector2, width: number, height: number);
7
- get position(): Vector2;
8
- get width(): number;
9
- get height(): number;
9
+ get x(): number;
10
+ get x1(): number;
11
+ get y(): number;
12
+ get y1(): number;
10
13
  }
@@ -3,15 +3,17 @@ import { Container } from "../utils/Container";
3
3
  import { Rectangle } from "../math/Rectangle";
4
4
  import { Vector2 } from "../math/Vector2";
5
5
  import { CollisionMatrix } from "../physics/collision/CollisionManager";
6
+ import { InitOptions } from "./GameActor";
6
7
  export declare const container: Container;
7
8
  export interface GameConfig {
8
- containerNode: HTMLElement | null;
9
+ containerNode?: HTMLElement | null;
9
10
  gameWidth?: number;
10
11
  gameHeight?: number;
11
12
  debugEnabled?: boolean;
12
13
  canvasColor?: string;
13
14
  physicsFramerate?: number;
14
15
  spriteDefaultScale?: Vector2 | null;
16
+ headless?: boolean;
15
17
  collisions?: {
16
18
  method?: CollisionMethodConfig;
17
19
  quadTreeBounds?: Rectangle | null;
@@ -43,9 +45,10 @@ export declare class Game {
43
45
  *
44
46
  * @param sceneClass the class of the scene
45
47
  * @param name The name of the scene
48
+ * @param options [optional] This options will be passed to the init method
46
49
  * @param openingScene [default FALSE] If this is the opening scene, set TRUE, FALSE instead
47
50
  */
48
- addScene(sceneClass: SceneClass, name: string, openingScene?: boolean): void;
51
+ addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
49
52
  /**
50
53
  * Run the game
51
54
  */
@@ -2,7 +2,7 @@ import { GameObject, GameObjectClass } from "./GameObject";
2
2
  import { GameObjectManager } from "./managers/GameObjectManager";
3
3
  import { FrameEvent } from "./managers/IterationManager";
4
4
  export interface InitOptions {
5
- [key: string]: unknown;
5
+ [key: string]: any;
6
6
  }
7
7
  export declare abstract class GameActor {
8
8
  protected readonly gameObjectManager: GameObjectManager;
@@ -25,6 +25,29 @@ export declare abstract class GameActor {
25
25
  * This method is called before destruction.
26
26
  */
27
27
  protected onDestroy?(): void;
28
+ /**
29
+ * Adds a new game object to the scene.
30
+ * @param gameObjectClass The game object class
31
+ * @returns The added game object
32
+ * @returns
33
+ */
34
+ protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
35
+ /**
36
+ * Adds a new game object to the scene.
37
+ * @param gameObjectClass The game object class
38
+ * @param name The name of the game object
39
+ * @returns The added game object
40
+ * @returns
41
+ */
42
+ protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, name: string): T;
43
+ /**
44
+ * Adds a new game object to the scene.
45
+ * @param gameObjectClass The game object class
46
+ * @param options This options will be passed to the init method
47
+ * @returns The added game object
48
+ * @returns
49
+ */
50
+ protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options: InitOptions): T;
28
51
  /**
29
52
  * Adds a new game object to the scene.
30
53
  * @param gameObjectClass The game object class
@@ -33,24 +56,30 @@ export declare abstract class GameActor {
33
56
  * @returns The added game object
34
57
  * @returns
35
58
  */
36
- protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, name?: string): T;
59
+ protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions | string, name?: string): T;
37
60
  /**
38
61
  * Returns all the game objects in the scene.
39
62
  * @returns The found game objects
40
63
  */
41
64
  protected findGameObjects(): GameObject[];
65
+ /**
66
+ * Returns a collection of found game objects for the given class
67
+ * @param gameObjectClass The game object class to find
68
+ * @returns The found game objects
69
+ */
70
+ protected findGameObjects<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T[];
42
71
  /**
43
72
  * Returns the first game object found for the given class, or undefined otherwise.
44
73
  * @param gameObjectClass The game object class to find
45
74
  * @returns The found game object
46
75
  */
47
- findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
76
+ protected findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
48
77
  /**
49
78
  * Returns the first game object found for the given name, or undefined otherwise.
50
79
  * @param name The name of the game object to find
51
80
  * @returns The found game object
52
81
  */
53
- findGameObject<T extends GameObject>(name: string): T;
82
+ protected findGameObject<T extends GameObject>(name: string): T;
54
83
  /**
55
84
  * Returns a collection of game objects found for the given tag
56
85
  * @param tag The tag of the game objects to find
@@ -12,7 +12,7 @@ export declare class GameObject extends GameActor {
12
12
  layer: string;
13
13
  ui: boolean;
14
14
  keep: boolean;
15
- parent: GameObject | null;
15
+ private _parent;
16
16
  private _active;
17
17
  private sceneManager;
18
18
  private components;
@@ -21,6 +21,8 @@ export declare class GameObject extends GameActor {
21
21
  constructor(name?: string, parent?: GameObject);
22
22
  get active(): boolean;
23
23
  set active(active: boolean);
24
+ get parent(): GameObject | null;
25
+ set parent(parent: GameObject | null);
24
26
  private updateComponentsActiveStatus;
25
27
  private updateChildrenActiveStatus;
26
28
  get transform(): Transform;
@@ -36,11 +38,31 @@ export declare class GameObject extends GameActor {
36
38
  /**
37
39
  * Add a component to the game obejct
38
40
  * @param componentClass The class of the component
39
- * @param options [optional] The options passed to the init method of the component
40
- * @param name [optional] The name of the component
41
41
  * @returns The added component
42
42
  */
43
- addComponent<ComponentType extends Component = Component, OptionsType extends InitOptions = InitOptions>(componentClass: ComponentClass<ComponentType>, options?: OptionsType, name?: string): ComponentType;
43
+ addComponent<ComponentType extends Component = Component>(componentClass: ComponentClass<ComponentType>): ComponentType;
44
+ /**
45
+ * Add a component to the game obejct
46
+ * @param componentClass The class of the component
47
+ * @param options The options passed to the init method of the component
48
+ * @returns The added component
49
+ */
50
+ addComponent<ComponentType extends Component = Component, OptionsType extends InitOptions = InitOptions>(componentClass: ComponentClass<ComponentType>, options: OptionsType): ComponentType;
51
+ /**
52
+ * Add a component to the game obejct
53
+ * @param componentClass The class of the component
54
+ * @param name The name of the component
55
+ * @returns The added component
56
+ */
57
+ addComponent<ComponentType extends Component = Component>(componentClass: ComponentClass<ComponentType>, name: string): ComponentType;
58
+ /**
59
+ * Add a component to the game obejct
60
+ * @param componentClass The class of the component
61
+ * @param options The options passed to the init method of the component
62
+ * @param name The name of the component
63
+ * @returns The added component
64
+ */
65
+ addComponent<ComponentType extends Component = Component, OptionsType extends InitOptions = InitOptions>(componentClass: ComponentClass<ComponentType>, options: OptionsType, name: string): ComponentType;
44
66
  private checkMultipleComponent;
45
67
  /**
46
68
  * Returns all the components in the game object.
@@ -17,7 +17,13 @@ export declare class GameObjectManagerFacade {
17
17
  * Returns all the game objects in the scene.
18
18
  * @returns The found game objects
19
19
  */
20
- static findGameObjects(): GameObject[];
20
+ static findAllGameObjects(): GameObject[];
21
+ /**
22
+ * Returns a collection of game objects found for the given class
23
+ * @param gameObjectClass The game object class to find
24
+ * @returns The found game objects
25
+ */
26
+ static findGameObjects<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T[];
21
27
  /**
22
28
  * Returns the first game object found for the given class, or undefined otherwise.
23
29
  * @param gameObjectClass The game object class to find
@@ -3,13 +3,16 @@ export declare enum AssetType {
3
3
  Audio = "Audio",
4
4
  Video = "Video"
5
5
  }
6
+ export interface IAssetManager {
7
+ getAssetsLoaded(): boolean;
8
+ loadImage(url: string): HTMLImageElement;
9
+ }
6
10
  export declare class AssetManager {
7
11
  private assets;
8
12
  getAssetsLoaded(): boolean;
9
- laadImage(url: string): HTMLImageElement;
13
+ loadImage(url: string): HTMLImageElement;
10
14
  loadAudio(url: string): HTMLAudioElement;
11
15
  getImage(url: string): HTMLImageElement;
12
- getVideo(url: string): HTMLVideoElement;
13
16
  getAudio(url: string): HTMLAudioElement;
14
17
  getAsset<EType extends HTMLImageElement | HTMLVideoElement | HTMLAudioElement>(url: string, type?: AssetType | null): EType;
15
18
  private createAsset;
@@ -3,7 +3,7 @@ import { InitOptions } from "../GameActor";
3
3
  export declare class GameObjectManager {
4
4
  private gameObjects;
5
5
  addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, parent?: GameObject, name?: string): T;
6
- findGameObjects(): GameObject[];
6
+ findGameObjects<T extends GameObject>(gameObjectClass?: GameObjectClass<T>): T[];
7
7
  findGameObjectById<T extends GameObject>(id: string): T;
8
8
  findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
9
9
  findGameObject<T extends GameObject>(name: string): T;
@@ -0,0 +1,29 @@
1
+ import { GameObjectManager } from "./GameObjectManager";
2
+ import { SceneManager } from "./SceneManager";
3
+ import { CollisionManager } from "../../physics/collision/CollisionManager";
4
+ import { RigidBodyManager } from "../../physics/rigodBody/RigidBodyManager";
5
+ import { TimeManager } from "./TimeManager";
6
+ import { IIterationManager } from "./IterationManager";
7
+ export declare class HeadlessIterationManager implements IIterationManager {
8
+ private readonly timeManager;
9
+ private readonly collisionManager;
10
+ private readonly physicsManager;
11
+ private readonly gameObjectManager;
12
+ private readonly sceneManager;
13
+ running: boolean;
14
+ private currentScene;
15
+ private gameObjects;
16
+ private components;
17
+ constructor(timeManager: TimeManager, collisionManager: CollisionManager, physicsManager: RigidBodyManager, gameObjectManager: GameObjectManager, sceneManager: SceneManager);
18
+ start(): void;
19
+ pause(): void;
20
+ resume(): void;
21
+ stop(): void;
22
+ private startLoop;
23
+ private gameLogicIteration;
24
+ private physicsIteration;
25
+ private asyncGameLoop;
26
+ private asyncPhysicsLoop;
27
+ private load;
28
+ private dispatchFrameEvent;
29
+ }
@@ -18,7 +18,14 @@ export declare enum FrameEvent {
18
18
  UpdateRender = 9,
19
19
  Destroy = 10
20
20
  }
21
- export declare class IterationManager {
21
+ export interface IIterationManager {
22
+ running: boolean;
23
+ start(): void;
24
+ pause(): void;
25
+ resume(): void;
26
+ stop(): void;
27
+ }
28
+ export declare class IterationManager implements IIterationManager {
22
29
  private readonly timeManager;
23
30
  private readonly collisionManager;
24
31
  private readonly physicsManager;
@@ -1,18 +1,19 @@
1
1
  import { Game } from "../Game";
2
2
  import { Scene } from "../Scene";
3
3
  import { RenderManager } from "../../rendering/RenderManager";
4
+ import { InitOptions } from "../GameActor";
4
5
  export declare type SceneClass = new (name: string, game: Game) => Scene;
5
6
  export declare class SceneManager {
6
7
  private game;
7
- private renderManager;
8
+ private renderManager?;
8
9
  private scenes;
9
10
  private currentScene;
10
11
  private openingSceneName;
11
12
  private sceneToLoad;
12
13
  currentSceneName: string;
13
- constructor(game: Game, renderManager: RenderManager);
14
+ constructor(game: Game, renderManager?: RenderManager);
14
15
  getCurrentScene<T extends Scene>(): T;
15
- addScene(sceneClass: SceneClass, name: string, openingScene?: boolean): void;
16
+ addScene(sceneClass: SceneClass, name: string, options?: InitOptions, openingScene?: boolean): void;
16
17
  loadOpeningScene(): void;
17
18
  loadScene(name: string): void;
18
19
  update(): void;
@@ -0,0 +1,29 @@
1
+ import { GameObjectManager } from "../GameObjectManager";
2
+ import { SceneManager } from "../SceneManager";
3
+ import { CollisionManager } from "../../../physics/collision/CollisionManager";
4
+ import { RigidBodyManager } from "../../../physics/rigodBody/RigidBodyManager";
5
+ import { TimeManager } from "../TimeManager";
6
+ import { IIterationManager } from "../IterationManager";
7
+ export declare class HeadlessIterationManager implements IIterationManager {
8
+ private readonly timeManager;
9
+ private readonly collisionManager;
10
+ private readonly physicsManager;
11
+ private readonly gameObjectManager;
12
+ private readonly sceneManager;
13
+ running: boolean;
14
+ private currentScene;
15
+ private gameObjects;
16
+ private components;
17
+ constructor(timeManager: TimeManager, collisionManager: CollisionManager, physicsManager: RigidBodyManager, gameObjectManager: GameObjectManager, sceneManager: SceneManager);
18
+ start(): void;
19
+ pause(): void;
20
+ resume(): void;
21
+ stop(): void;
22
+ private startLoop;
23
+ private gameLogicIteration;
24
+ private physicsIteration;
25
+ private asyncGameLoop;
26
+ private asyncPhysicsLoop;
27
+ private load;
28
+ private dispatchFrameEvent;
29
+ }
@@ -0,0 +1,10 @@
1
+ import { CameraData } from "../../../rendering/CameraData";
2
+ import { RenderData } from "../../../rendering/renderData/RenderData";
3
+ import { IRenderManager } from "../../../rendering/RenderManager";
4
+ export declare class HeadlessRenderManager implements IRenderManager {
5
+ clearCanvas(): void;
6
+ addRenderData(renderData: RenderData): void;
7
+ addCameraData(cameraData: CameraData): void;
8
+ render(): void;
9
+ clearData(): void;
10
+ }
@@ -0,0 +1,35 @@
1
+ import { GameObjectManager } from "../GameObjectManager";
2
+ import { SceneManager } from "../SceneManager";
3
+ import { InputManager } from "../../../input/InputManager";
4
+ import { CollisionManager } from "../../../physics/collision/CollisionManager";
5
+ import { RigidBodyManager } from "../../../physics/rigodBody/RigidBodyManager";
6
+ import { RenderManager } from "../../../rendering/RenderManager";
7
+ import { TimeManager } from "../TimeManager";
8
+ import { IIterationManager } from "./IIterationManager";
9
+ export declare class BrowserIterationManager implements IIterationManager {
10
+ private readonly timeManager;
11
+ private readonly collisionManager;
12
+ private readonly physicsManager;
13
+ private readonly renderManager;
14
+ private readonly inputManager;
15
+ private readonly gameObjectManager;
16
+ private readonly sceneManager;
17
+ running: boolean;
18
+ private gameLoopAccumulator;
19
+ private currentScene;
20
+ private gameObjects;
21
+ private components;
22
+ constructor(timeManager: TimeManager, collisionManager: CollisionManager, physicsManager: RigidBodyManager, renderManager: RenderManager, inputManager: InputManager, gameObjectManager: GameObjectManager, sceneManager: SceneManager);
23
+ start(): void;
24
+ pause(): void;
25
+ resume(): void;
26
+ stop(): void;
27
+ private startLoop;
28
+ private requestAnimationLoop;
29
+ private gameLogicIteration;
30
+ private renderIteration;
31
+ private physicsIteration;
32
+ private asyncPhysicsLoop;
33
+ private load;
34
+ private dispatchFrameEvent;
35
+ }
@@ -0,0 +1,13 @@
1
+ export declare enum FrameEvent {
2
+ Init = 0,
3
+ Start = 1,
4
+ Update = 2,
5
+ UpdateEngine = 3,
6
+ UpdateCollider = 4,
7
+ UpdatePhysics = 5,
8
+ UpdateTransform = 6,
9
+ UpdatePreRender = 7,
10
+ UpdateCamera = 8,
11
+ UpdateRender = 9,
12
+ Destroy = 10
13
+ }
@@ -0,0 +1,29 @@
1
+ import { GameObjectManager } from "../GameObjectManager";
2
+ import { SceneManager } from "../SceneManager";
3
+ import { CollisionManager } from "../../../physics/collision/CollisionManager";
4
+ import { RigidBodyManager } from "../../../physics/rigodBody/RigidBodyManager";
5
+ import { TimeManager } from "../TimeManager";
6
+ import { IIterationManager } from "./IIterationManager";
7
+ export declare class HeadlessIterationManager implements IIterationManager {
8
+ private readonly timeManager;
9
+ private readonly collisionManager;
10
+ private readonly physicsManager;
11
+ private readonly gameObjectManager;
12
+ private readonly sceneManager;
13
+ running: boolean;
14
+ private currentScene;
15
+ private gameObjects;
16
+ private components;
17
+ constructor(timeManager: TimeManager, collisionManager: CollisionManager, physicsManager: RigidBodyManager, gameObjectManager: GameObjectManager, sceneManager: SceneManager);
18
+ start(): void;
19
+ pause(): void;
20
+ resume(): void;
21
+ stop(): void;
22
+ private startLoop;
23
+ private gameLogicIteration;
24
+ private physicsIteration;
25
+ private asyncGameLoop;
26
+ private asyncPhysicsLoop;
27
+ private load;
28
+ private dispatchFrameEvent;
29
+ }
@@ -0,0 +1,7 @@
1
+ export interface IIterationManager {
2
+ running: boolean;
3
+ start(): void;
4
+ pause(): void;
5
+ resume(): void;
6
+ stop(): void;
7
+ }