angry-pixel 1.2.3 → 1.2.4

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.
Files changed (142) hide show
  1. package/README.md +170 -168
  2. package/api-docs/.nojekyll +1 -0
  3. package/api-docs/assets/highlight.css +92 -0
  4. package/api-docs/assets/main.js +59 -0
  5. package/api-docs/assets/navigation.js +1 -0
  6. package/api-docs/assets/search.js +1 -0
  7. package/api-docs/assets/style.css +1383 -0
  8. package/api-docs/classes/Animator.html +128 -0
  9. package/api-docs/classes/AudioPlayer.html +131 -0
  10. package/api-docs/classes/BallCollider.html +132 -0
  11. package/api-docs/classes/BoxCollider.html +136 -0
  12. package/api-docs/classes/Button.html +125 -0
  13. package/api-docs/classes/Camera.html +114 -0
  14. package/api-docs/classes/Component.html +106 -0
  15. package/api-docs/classes/EdgeCollider.html +134 -0
  16. package/api-docs/classes/Game.html +24 -0
  17. package/api-docs/classes/GameCamera.html +163 -0
  18. package/api-docs/classes/GameObject.html +149 -0
  19. package/api-docs/classes/GamepadController.html +11 -0
  20. package/api-docs/classes/GamepadData.html +81 -0
  21. package/api-docs/classes/KeyboardController.html +43 -0
  22. package/api-docs/classes/MaskRenderer.html +119 -0
  23. package/api-docs/classes/MouseController.html +14 -0
  24. package/api-docs/classes/PhysicsComponent.html +107 -0
  25. package/api-docs/classes/PolygonCollider.html +134 -0
  26. package/api-docs/classes/PreRenderComponent.html +107 -0
  27. package/api-docs/classes/Rectangle.html +30 -0
  28. package/api-docs/classes/RigidBody.html +123 -0
  29. package/api-docs/classes/Rotation.html +5 -0
  30. package/api-docs/classes/Scene.html +73 -0
  31. package/api-docs/classes/SpacePointer.html +147 -0
  32. package/api-docs/classes/Sprite.html +20 -0
  33. package/api-docs/classes/SpriteRenderer.html +134 -0
  34. package/api-docs/classes/TextRenderer.html +138 -0
  35. package/api-docs/classes/TiledTilemapRenderer.html +127 -0
  36. package/api-docs/classes/TilemapCollider.html +124 -0
  37. package/api-docs/classes/TilemapRenderer.html +126 -0
  38. package/api-docs/classes/TouchController.html +8 -0
  39. package/api-docs/classes/Transform.html +124 -0
  40. package/api-docs/classes/Vector2.html +65 -0
  41. package/api-docs/classes/VideoRenderer.html +145 -0
  42. package/api-docs/enums/BroadPhaseMethods.html +3 -0
  43. package/api-docs/enums/ButtonType.html +3 -0
  44. package/api-docs/enums/CollisionMethods.html +3 -0
  45. package/api-docs/enums/RigidBodyType.html +4 -0
  46. package/api-docs/enums/TextOrientation.html +5 -0
  47. package/api-docs/enums/TilemapOrientation.html +5 -0
  48. package/api-docs/functions/between.html +5 -0
  49. package/api-docs/functions/clamp.html +5 -0
  50. package/api-docs/functions/fixedRound.html +4 -0
  51. package/api-docs/functions/randomFloat.html +4 -0
  52. package/api-docs/functions/randomInt.html +4 -0
  53. package/api-docs/functions/range.html +5 -0
  54. package/api-docs/index.html +37 -0
  55. package/api-docs/interfaces/AnimationConfig.html +10 -0
  56. package/api-docs/interfaces/AnimatorOptions.html +6 -0
  57. package/api-docs/interfaces/AudioPlayerOptions.html +8 -0
  58. package/api-docs/interfaces/BallColliderOptions.html +16 -0
  59. package/api-docs/interfaces/BoxColliderOptions.html +20 -0
  60. package/api-docs/interfaces/ButtonOptions.html +16 -0
  61. package/api-docs/interfaces/ColliderComponent.html +14 -0
  62. package/api-docs/interfaces/CollisionData.html +10 -0
  63. package/api-docs/interfaces/EdgeColliderOptions.html +18 -0
  64. package/api-docs/interfaces/GameConfig.html +28 -0
  65. package/api-docs/interfaces/IAssetManager.html +40 -0
  66. package/api-docs/interfaces/ICollider.html +11 -0
  67. package/api-docs/interfaces/ICollision.html +4 -0
  68. package/api-docs/interfaces/ICollisionResolution.html +4 -0
  69. package/api-docs/interfaces/IDomManager.html +6 -0
  70. package/api-docs/interfaces/IGameObjectManager.html +49 -0
  71. package/api-docs/interfaces/IInputManager.html +12 -0
  72. package/api-docs/interfaces/IPhysicsManager.html +8 -0
  73. package/api-docs/interfaces/IRenderManager.html +7 -0
  74. package/api-docs/interfaces/ISceneManager.html +18 -0
  75. package/api-docs/interfaces/ITimeManager.html +16 -0
  76. package/api-docs/interfaces/MaskRendererOptions.html +18 -0
  77. package/api-docs/interfaces/PolygonColliderOptions.html +18 -0
  78. package/api-docs/interfaces/RigidBodyOptions.html +17 -0
  79. package/api-docs/interfaces/Slice.html +5 -0
  80. package/api-docs/interfaces/SpriteConfig.html +10 -0
  81. package/api-docs/interfaces/SpriteRendererOptions.html +32 -0
  82. package/api-docs/interfaces/TextRendererOptions.html +38 -0
  83. package/api-docs/interfaces/TiledChunk.html +7 -0
  84. package/api-docs/interfaces/TiledLayer.html +17 -0
  85. package/api-docs/interfaces/TiledTilemap.html +9 -0
  86. package/api-docs/interfaces/TiledTilemapRendererOptions.html +18 -0
  87. package/api-docs/interfaces/TilemapColliderOptions.html +12 -0
  88. package/api-docs/interfaces/TilemapRendererOptions.html +22 -0
  89. package/api-docs/interfaces/Tileset.html +13 -0
  90. package/api-docs/interfaces/TouchInteraction.html +6 -0
  91. package/api-docs/interfaces/VideoRendererOptions.html +34 -0
  92. package/api-docs/modules.html +85 -0
  93. package/api-docs/types/CollisionMatrix.html +1 -0
  94. package/lib/component/Animator.d.ts +114 -8
  95. package/lib/component/AudioPlayer.d.ts +44 -6
  96. package/lib/component/Button.d.ts +82 -7
  97. package/lib/component/Camera.d.ts +27 -0
  98. package/lib/component/RigidBody.d.ts +75 -0
  99. package/lib/component/Sprite.d.ts +31 -3
  100. package/lib/component/Transform.d.ts +35 -0
  101. package/lib/component/collider/BallCollider.d.ts +48 -0
  102. package/lib/component/collider/BoxCollider.d.ts +57 -0
  103. package/lib/component/collider/Collider.d.ts +47 -1
  104. package/lib/component/collider/EdgeCollider.d.ts +52 -0
  105. package/lib/component/collider/PolygonCollider.d.ts +53 -0
  106. package/lib/component/collider/TilemapCollider.d.ts +41 -0
  107. package/lib/component/rendering/MaskRenderer.d.ts +56 -0
  108. package/lib/component/rendering/Sprite.d.ts +61 -0
  109. package/lib/component/rendering/SpriteRenderer.d.ts +92 -2
  110. package/lib/component/rendering/TextRenderer.d.ts +103 -4
  111. package/lib/component/rendering/TiledTilemapRenderer.d.ts +110 -3
  112. package/lib/component/rendering/TilemapRenderer.d.ts +120 -5
  113. package/lib/component/rendering/VideoRenderer.d.ts +91 -1
  114. package/lib/core/Component.d.ts +118 -0
  115. package/lib/core/Game.d.ts +47 -2
  116. package/lib/core/GameActor.d.ts +20 -4
  117. package/lib/core/GameConfig.d.ts +45 -2
  118. package/lib/core/GameObject.d.ts +63 -0
  119. package/lib/core/Scene.d.ts +32 -0
  120. package/lib/core/ioc/Config.d.ts +2 -1
  121. package/lib/core/managers/AssetManager.d.ts +68 -6
  122. package/lib/core/managers/DomManager.d.ts +11 -0
  123. package/lib/core/managers/GameObjectManager.d.ts +81 -0
  124. package/lib/core/managers/HeadlessIterationManager.d.ts +1 -0
  125. package/lib/core/managers/IterationManager.d.ts +4 -0
  126. package/lib/core/managers/SceneManager.d.ts +29 -1
  127. package/lib/core/managers/TimeManager.d.ts +37 -2
  128. package/lib/gameObject/GameCamera.d.ts +22 -0
  129. package/lib/gameObject/SpacePointer.d.ts +7 -0
  130. package/lib/index.cjs.js +1 -1
  131. package/lib/index.d.ts +1 -1
  132. package/lib/index.esm.js +1 -1
  133. package/lib/index.js +1 -1
  134. package/lib/input/GamepadController.d.ts +176 -2
  135. package/lib/input/InputManager.d.ts +18 -0
  136. package/lib/input/KeyboardController.d.ts +70 -1
  137. package/lib/input/MouseController.d.ts +35 -0
  138. package/lib/input/TouchController.d.ts +36 -4
  139. package/lib/utils/Container.d.ts +1 -0
  140. package/lib/utils/Exception.d.ts +1 -0
  141. package/package.json +9 -5
  142. package/typedoc.json +13 -0
@@ -2,26 +2,81 @@ import { TilemapOrientation } from "angry-pixel-2d-renderer";
2
2
  import { Vector2 } from "angry-pixel-math";
3
3
  import { RenderComponent } from "../../core/Component";
4
4
  export { TilemapOrientation };
5
+ /**
6
+ * Tileset configuration to be used with the TilemapRenderer
7
+ * @public
8
+ * @category Components
9
+ * @example
10
+ * ```js
11
+ * const tileset = {
12
+ * image: this.assetManager.getImage("image.png"),
13
+ * width: 3,
14
+ * tileWidth: 16,
15
+ * tileHeight: 16,
16
+ * margin: new Vector2(0, 0),
17
+ * spacing: new Vector2(0, 0),
18
+ * };
19
+ * ```
20
+ */
5
21
  export interface Tileset {
22
+ /** The tileset image element */
6
23
  image: HTMLImageElement;
7
24
  width: number;
8
25
  tileWidth: number;
9
26
  tileHeight: number;
27
+ /** Margin of the tile in pixels (space in the top and the left) */
10
28
  margin?: Vector2;
29
+ /** Spacing of the tile in pixels (space in the bottom and the right) */
11
30
  spacing?: Vector2;
12
31
  }
32
+ /**
33
+ * TilemapRenderer configuration options
34
+ * @public
35
+ * @category Components
36
+ * @example
37
+ * ```js
38
+ * this.addComponent(TilemapRenderer, {
39
+ * tileset: {
40
+ * image: this.assetManager.getImage("image.png"),
41
+ * width: 3,
42
+ * tileWidth: 16,
43
+ * tileHeight: 16,
44
+ * margin: new Vector2(0, 0),
45
+ * spacing: new Vector2(0, 0),
46
+ * }
47
+ * tiles: [1, 2, 0, 0, 0, 0, 2, 1, 3, 4, 5, 5, 5, 5, 4, 3],
48
+ * width: 8,
49
+ * tileWidth: 16,
50
+ * tileHeight: 16,
51
+ * layer: "Tilemap",
52
+ * orientation: TilemapOrientation.Center,
53
+ * smooth: false,
54
+ * });
55
+ * ```
56
+ */
13
57
  export interface TilemapRendererOptions {
58
+ /** Id of tiles separated by commas. The ids start at 1, and increment from left to right,
59
+ * from top to bottom. ID 0 (zero) represents a space with no tile. */
14
60
  tiles: string;
61
+ /** The Tileset instance */
15
62
  tileset: Tileset;
16
63
  width: number;
17
64
  tileWidth: number;
18
65
  tileHeight: number;
66
+ /** The render layer */
19
67
  layer?: string;
68
+ /** Direction in which the tilemap will be rendered. */
20
69
  orientation?: TilemapOrientation;
21
- alpha?: number;
70
+ /** Change the opacity between 1 and 0 */
71
+ opacity?: number;
72
+ /** Define a color for tinting the tiles */
22
73
  tintColor?: string;
74
+ /** Smoothing pixels (not recommended for pixel art) */
23
75
  smooth?: boolean;
24
76
  }
77
+ /**
78
+ * @private
79
+ */
25
80
  export interface ITilemapRenderer {
26
81
  tiles: number[];
27
82
  width: number;
@@ -32,23 +87,83 @@ export interface ITilemapRenderer {
32
87
  realWidth: number;
33
88
  realHeight: number;
34
89
  }
90
+ /**
91
+ * The TilemapRenderer component allows you to render a tile map defined by an array of tile ids, using an instance of the TileSet object.
92
+ * @public
93
+ * @category Components
94
+ * @example
95
+ * ```js
96
+ * this.addComponent(TilemapRenderer, {
97
+ * tileset: {
98
+ * image: this.assetManager.getImage("image.png"),
99
+ * width: 3,
100
+ * tileWidth: 16,
101
+ * tileHeight: 16,
102
+ * }
103
+ * tiles: [1, 2, 0, 0, 0, 0, 2, 1, 3, 4, 5, 5, 5, 5, 4, 3],
104
+ * width: 8,
105
+ * tileWidth: 16,
106
+ * tileHeight: 16,
107
+ * });
108
+ * ```
109
+ * @example
110
+ * ```js
111
+ * this.addComponent(TilemapRenderer, {
112
+ * tileset: {
113
+ * image: this.assetManager.getImage("image.png"),
114
+ * width: 3,
115
+ * tileWidth: 16,
116
+ * tileHeight: 16,
117
+ * margin: new Vector2(0, 0),
118
+ * spacing: new Vector2(0, 0),
119
+ * }
120
+ * tiles: [1, 2, 0, 0, 0, 0, 2, 1, 3, 4, 5, 5, 5, 5, 4, 3],
121
+ * width: 8,
122
+ * tileWidth: 16,
123
+ * tileHeight: 16,
124
+ * layer: "Tilemap",
125
+ * orientation: TilemapOrientation.Center,
126
+ * smooth: false,
127
+ * });
128
+ * ```
129
+ */
35
130
  export declare class TilemapRenderer extends RenderComponent implements ITilemapRenderer {
131
+ /** Id of tiles separated by commas. The ids start at 1, and increment from left to right,
132
+ * from top to bottom. ID 0 (zero) represents a space with no tile. */
36
133
  tiles: number[];
134
+ /** The width of the tilemap in tiles */
37
135
  width: number;
136
+ /**
137
+ * The height of the tilemap in tiles (this is calculated by the component)
138
+ * @readonly
139
+ */
38
140
  height: number;
141
+ /** The width of the tile to render in pixels */
39
142
  tileWidth: number;
143
+ /** The height of the tile to render in pixels */
40
144
  tileHeight: number;
145
+ /** Define a color for tinting the tiles */
41
146
  tintColor: string;
42
- alpha: number;
147
+ /** Change the opacity between 1 and 0 */
148
+ opacity: number;
149
+ /** Direction in which the tilemap will be rendered (default value TilemapOrientation.Center) */
43
150
  orientation: TilemapOrientation;
151
+ /**
152
+ * Tilemap width in pixels (this is calculated by the component)
153
+ * @readonly
154
+ */
155
+ realWidth: number;
156
+ /**
157
+ * Tilemap height in pixels (this is calculated by the component)
158
+ * @readonly
159
+ */
160
+ realHeight: number;
44
161
  private tileset;
45
162
  private renderData;
46
163
  private layer;
47
164
  private scaledTileWidth;
48
165
  private scaledTileHeight;
49
- realWidth: number;
50
- realHeight: number;
51
- protected init({ tiles, tileset, tileWidth, tileHeight, width, layer, orientation, alpha, tintColor, smooth, }: TilemapRendererOptions): void;
166
+ protected init({ tiles, tileset, tileWidth, tileHeight, width, layer, orientation, opacity, tintColor, smooth, }: TilemapRendererOptions): void;
52
167
  protected update(): void;
53
168
  private updateRenderData;
54
169
  }
@@ -1,36 +1,120 @@
1
1
  import { RenderComponent } from "../../core/Component";
2
2
  import { Rotation, Vector2 } from "angry-pixel-math";
3
3
  import { Slice } from "angry-pixel-2d-renderer";
4
+ /**
5
+ * VideoRenderer configuration options.
6
+ * @public
7
+ * @category Components
8
+ * @example
9
+ * ```js
10
+ * this.addComponent(VideoRenderer, {
11
+ * video: this.assetManager.getVideo("video.mp4"),
12
+ * width: 1920,
13
+ * height: 1080,
14
+ * offset: new Vector2(0, 0),
15
+ * flipHorizontal: false,
16
+ * flipVertical: false,
17
+ * rotation: new Rotation(0),
18
+ * opacity: 1,
19
+ * maskColor: "#FF0000",
20
+ * maskColorMix: 0,
21
+ * tintColor: "#00FF00",
22
+ * layer: "Video",
23
+ * slice: {x: 0, y:0, width: 1920, height: 1080},
24
+ * volume: 1,
25
+ * loop: false,
26
+ * });
27
+ * ```
28
+ */
4
29
  export interface VideoRendererOptions {
30
+ /**The video element to render */
5
31
  video: HTMLVideoElement;
32
+ /** Overwrite the original video width */
6
33
  width?: number;
34
+ /** Overwrite the original video height */
7
35
  height?: number;
36
+ /** X-axis and Y-axis offset */
8
37
  offset?: Vector2;
38
+ /** Video rotation (degrees or radians) */
9
39
  rotation?: Rotation;
40
+ /** Flip the video horizontally */
10
41
  flipHorizontal?: boolean;
42
+ /** Flip the video vertically */
11
43
  flipVertical?: boolean;
44
+ /** Change the opacity between 1 and 0 */
12
45
  opacity?: number;
46
+ /** Define a mask color for the video */
13
47
  maskColor?: string;
48
+ /** Define the opacity of the mask color between 1 and 0 */
14
49
  maskColorMix?: number;
50
+ /** Define a color for tinting the video */
15
51
  tintColor?: string;
52
+ /** The render layer */
16
53
  layer?: string;
54
+ /** Cut the video based on straight coordinates starting from the top left downward */
17
55
  slice?: Slice;
56
+ /** The volume of the video. Values between 1 and 0 */
18
57
  volume?: number;
58
+ /** TRUE if the video will play in loop */
19
59
  loop?: boolean;
20
60
  }
61
+ /**
62
+ * The VideoRenderer component plays and renders a video element, and allows configuring options such as its dimensions, coloring, etc.
63
+ * @public
64
+ * @category Components
65
+ * @example
66
+ * ```js
67
+ * this.addComponent(VideoRenderer, {
68
+ * video: this.assetManager.getVideo("video.mp4"),
69
+ * });
70
+ * ```
71
+ * @example
72
+ * ```js
73
+ * this.addComponent(VideoRenderer, {
74
+ * video: this.assetManager.getVideo("video.mp4"),
75
+ * width: 1920,
76
+ * height: 1080,
77
+ * offset: new Vector2(0, 0),
78
+ * flipHorizontal: false,
79
+ * flipVertical: false,
80
+ * rotation: new Rotation(0),
81
+ * opacity: 1,
82
+ * maskColor: "#FF0000",
83
+ * maskColorMix: 0,
84
+ * tintColor: "#00FF00",
85
+ * layer: "Video",
86
+ * slice: {x: 0, y:0, width: 1920, height: 1080},
87
+ * volume: 1,
88
+ * loop: false,
89
+ * });
90
+ * ```
91
+ */
21
92
  export declare class VideoRenderer extends RenderComponent {
93
+ /**The video element to render */
22
94
  video: HTMLVideoElement;
95
+ /** Overwrite the original video width */
23
96
  width: number;
97
+ /** Overwrite the original video height */
24
98
  height: number;
99
+ /** X-axis and Y-axis offset */
25
100
  offset: Vector2;
101
+ /** Video rotation (degrees or radians) */
102
+ rotation: Rotation;
103
+ /** Flip the video horizontally */
26
104
  flipHorizontal: boolean;
105
+ /** Flip the video vertically */
27
106
  flipVertical: boolean;
28
- rotation: Rotation;
107
+ /** Change the opacity between 1 and 0 */
29
108
  opacity: number;
109
+ /** Define a mask color for the video */
30
110
  maskColor: string;
111
+ /** Define the opacity of the mask color between 1 and 0 */
31
112
  maskColorMix: number;
113
+ /** Define a color for tinting the video */
32
114
  tintColor: string;
115
+ /** The render layer */
33
116
  layer: string;
117
+ /** Cut the video based on straight coordinates starting from the top left downward */
34
118
  slice?: Slice;
35
119
  private renderData;
36
120
  private innerPosition;
@@ -39,11 +123,17 @@ export declare class VideoRenderer extends RenderComponent {
39
123
  private _volume;
40
124
  private _playing;
41
125
  private _paused;
126
+ /** The volume of the video */
42
127
  set volume(volume: number);
128
+ /** The volume of the video */
43
129
  get volume(): number;
130
+ /** TRUE if the video will play in loop */
44
131
  set loop(loop: boolean);
132
+ /** TRUE if the video will play in loop */
45
133
  get loop(): boolean;
134
+ /** TRUE if the video is playing */
46
135
  get playing(): boolean;
136
+ /** TRUE if the video is paused */
47
137
  get paused(): boolean;
48
138
  protected init(config: VideoRendererOptions): void;
49
139
  /**
@@ -3,14 +3,55 @@ 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
+ /** @private */
6
7
  export type ComponentClass<T extends Component = Component> = new (container: Container, gameObject: GameObject, name?: string) => T;
8
+ /**
9
+ * Base class for all components to be added to game objects.
10
+ * @public
11
+ * @category Core
12
+ * @example
13
+ * ```js
14
+ * class MovementsController extends Component {
15
+ * init(options) {
16
+ * // executed after instantiation
17
+ * }
18
+ * start() {
19
+ * // executed in the first available frame
20
+ * }
21
+ * update() {
22
+ * // executed on every frame
23
+ * }
24
+ * }
25
+ * ```
26
+ * @example
27
+ * ```ts
28
+ * class MovementsController extends Component {
29
+ * protected init(options?: InitOptions): void {
30
+ * // executed after instantiation
31
+ * }
32
+ * protected start(): void {
33
+ * // executed in the first available frame
34
+ * }
35
+ * protected update(): void {
36
+ * // executed on every frame
37
+ * }
38
+ * }
39
+ * ```
40
+ */
7
41
  export declare abstract class Component extends GameActor {
42
+ /** Name given manually at the time of instantiation. */
8
43
  readonly name: string;
44
+ /** Object to which it belongs. */
9
45
  readonly gameObject: GameObject;
46
+ /** TRUE if several instances of this component are allowed in the same object. */
10
47
  readonly allowMultiple: boolean;
48
+ /** @private */
11
49
  private _active;
50
+ /** @private */
12
51
  constructor(container: Container, gameObject: GameObject, name?: string);
52
+ /** TRUE for enabled object, FALSE for disabled object. */
13
53
  get active(): boolean;
54
+ /** TRUE for enabled object, FALSE for disabled object. */
14
55
  set active(active: boolean);
15
56
  /**
16
57
  * This method is called when the active state changes.
@@ -58,28 +99,105 @@ export declare abstract class Component extends GameActor {
58
99
  * @returns boolean
59
100
  */
60
101
  hasComponent(name: string): boolean;
102
+ /**
103
+ * Removes the given component in the GameObject
104
+ * @param component The class of the component to remnove
105
+ */
61
106
  removeComponent(component: Component): void;
107
+ /** @private */
62
108
  protected _destroy(): void;
109
+ /** @private */
63
110
  protected _stopGame(): void;
64
111
  }
112
+ /** @private */
65
113
  export declare abstract class EngineComponent extends Component {
66
114
  protected readonly updateEvent: FrameEvent;
67
115
  }
116
+ /** @private */
68
117
  export declare abstract class ColliderComponent extends Component {
69
118
  protected readonly updateEvent: FrameEvent;
70
119
  }
120
+ /**
121
+ * Base class for all components that execute logic at physics frame rate. Ideal for custom physics.
122
+ * @public
123
+ * @category Core
124
+ * @example
125
+ * ```js
126
+ * class PlayerMovements extends PhysicsComponent {
127
+ * init(options) {
128
+ * // executed after instantiation
129
+ * }
130
+ * start() {
131
+ * // executed in the first available frame
132
+ * }
133
+ * update() {
134
+ * // executed on every frame
135
+ * }
136
+ * }
137
+ * ```
138
+ * @example
139
+ * ```ts
140
+ * class PlayerMovements extends PhysicsComponent {
141
+ * protected init(options?: InitOptions): void {
142
+ * // executed after instantiation
143
+ * }
144
+ * protected start(): void {
145
+ * // executed in the first available frame
146
+ * }
147
+ * protected update(): void {
148
+ * // executed on every frame
149
+ * }
150
+ * }
151
+ * ```
152
+ */
71
153
  export declare abstract class PhysicsComponent extends Component {
72
154
  protected readonly updateEvent: FrameEvent;
73
155
  }
156
+ /** @private */
74
157
  export declare abstract class TransformComponent extends Component {
75
158
  protected readonly updateEvent: FrameEvent;
76
159
  }
160
+ /**
161
+ * Base class for all components that execute logic before rendering. Ideal for components that translate cameras.
162
+ * @public
163
+ * @category Core
164
+ * @example
165
+ * ```js
166
+ * class FollowPlayerCamera extends PreRenderComponent {
167
+ * init(options) {
168
+ * // executed after instantiation
169
+ * }
170
+ * start() {
171
+ * // executed in the first available frame
172
+ * }
173
+ * update() {
174
+ * // executed on every frame
175
+ * }
176
+ * }
177
+ * ```
178
+ * @example
179
+ * ```ts
180
+ * class FollowPlayerCamera extends PreRenderComponent {
181
+ * protected init(options?: InitOptions): void {
182
+ * // executed after instantiation
183
+ * }
184
+ * protected start(): void {
185
+ * // executed in the first available frame
186
+ * }
187
+ * protected update(): void {
188
+ * // executed on every frame
189
+ * }
190
+ * }
191
+ * ```
192
+ */
77
193
  export declare abstract class PreRenderComponent extends Component {
78
194
  protected readonly updateEvent: FrameEvent;
79
195
  }
196
+ /** @private */
80
197
  export declare abstract class CameraComponent extends Component {
81
198
  protected readonly updateEvent: FrameEvent;
82
199
  }
200
+ /** @private */
83
201
  export declare abstract class RenderComponent extends Component {
84
202
  protected readonly updateEvent: FrameEvent;
85
203
  }
@@ -1,19 +1,64 @@
1
1
  import { InitOptions } from "./GameActor";
2
2
  import { GameConfig } from "./GameConfig";
3
3
  import { SceneClass } from "./Scene";
4
+ /**
5
+ * Game is the main class that contains all the managers, scenes, objects and components. It allows to start and stop the execution of the game.
6
+ * @public
7
+ * @category Core
8
+ * @example
9
+ * ```js
10
+ * const game = new Game({
11
+ * containerNode: document.getElementById("app"),
12
+ * gameWidth: 1920,
13
+ * gameHeight: 1080,
14
+ * });
15
+ * game.addScene(GameScene, "GameScene");
16
+ * game.run();
17
+ * ```
18
+ * @example
19
+ * ```js
20
+ * const game = new Game({
21
+ * containerNode: document.getElementById("app"),
22
+ * gameWidth: 1920,
23
+ * gameHeight: 1080,
24
+ * debugEnabled: false,
25
+ * canvasColor: "#000000",
26
+ * physicsFramerate: 180,
27
+ * headless: false,
28
+ * spriteDefaultScale: new Vector2(1, 1),
29
+ * collisions: {
30
+ * collisionMatrix: [
31
+ * ["layer1", "layer2"],
32
+ * ["layer1", "layer3"],
33
+ * ],
34
+ * collisionMethod: CollisionMethods.SAT,
35
+ * collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
36
+ * collisionArea: new Rectangle(-960, -540, 1920, 1080),
37
+ * }
38
+ * });
39
+ * game.addScene(GameScene, "GameScene");
40
+ * game.run();
41
+ * ```
42
+ */
4
43
  export declare class Game {
44
+ /** @private */
5
45
  private readonly container;
46
+ /** @private */
6
47
  private sceneManager;
48
+ /** @private */
7
49
  private iterationManager;
50
+ /** @private */
8
51
  private _config;
52
+ /** @private */
9
53
  constructor(config: GameConfig);
54
+ /** @private */
10
55
  private setupManagers;
11
56
  /**
12
- * @returns GameConfig
57
+ * The game configuration
13
58
  */
14
59
  get config(): GameConfig;
15
60
  /**
16
- * @returns running
61
+ * TRUE if the game is running
17
62
  */
18
63
  get running(): boolean;
19
64
  /**
@@ -10,23 +10,41 @@ import { FrameEvent } from "./managers/IterationManager";
10
10
  import { ISceneManager } from "./managers/SceneManager";
11
11
  import { ITimeManager } from "./managers/TimeManager";
12
12
  import { IRenderManager } from "angry-pixel-2d-renderer";
13
+ /** @private */
13
14
  export interface InitOptions {
14
15
  [key: string]: any;
15
16
  }
17
+ /**
18
+ * Base class from which Scene, GameObjects and Component are extended.
19
+ * @private
20
+ */
16
21
  export declare abstract class GameActor {
22
+ /** @private */
17
23
  protected readonly updateEvent: FrameEvent;
24
+ /** @private */
18
25
  protected readonly container: Container;
26
+ /** Used to load and retrieve assets. */
19
27
  protected readonly assetManager: IAssetManager;
28
+ /** Used to access the canvas element. */
20
29
  protected readonly domManager: IDomManager;
30
+ /** Used to obtain information about the input. */
21
31
  protected readonly inputManager: IInputManager;
32
+ /** Used to create, retrieve and destroy GameObject instances. */
22
33
  protected readonly gameObjectManager: IGameObjectManager;
34
+ /** Used to manage colliders and rigidBodies. */
23
35
  protected readonly physicsManager: IPhysicsManager;
36
+ /** Used to manage the render and camera data. */
24
37
  protected readonly renderManager: IRenderManager;
38
+ /** Used to load scenes. */
25
39
  protected readonly sceneManager: ISceneManager;
40
+ /** Used to manage and obtain information about the time in the game. */
26
41
  protected readonly timeManager: ITimeManager;
42
+ /** Object containing the game configuration. */
27
43
  protected readonly gameConfig: GameConfig;
28
44
  private started;
45
+ /** @private */
29
46
  constructor(container: Container);
47
+ /** @private */
30
48
  dispatch(event: FrameEvent, options?: InitOptions): void;
31
49
  /**
32
50
  * This method is called after instantiation (recommended for the creation of game objects).
@@ -48,7 +66,6 @@ export declare abstract class GameActor {
48
66
  * Adds a new game object to the scene.
49
67
  * @param gameObjectClass The game object class
50
68
  * @returns The added game object
51
- * @returns
52
69
  */
53
70
  protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
54
71
  /**
@@ -56,7 +73,6 @@ export declare abstract class GameActor {
56
73
  * @param gameObjectClass The game object class
57
74
  * @param name The name of the game object
58
75
  * @returns The added game object
59
- * @returns
60
76
  */
61
77
  protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, name: string): T;
62
78
  /**
@@ -64,7 +80,6 @@ export declare abstract class GameActor {
64
80
  * @param gameObjectClass The game object class
65
81
  * @param options This options will be passed to the init method
66
82
  * @returns The added game object
67
- * @returns
68
83
  */
69
84
  protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options: InitOptions): T;
70
85
  /**
@@ -73,7 +88,6 @@ export declare abstract class GameActor {
73
88
  * @param options [optional] This options will be passed to the init method
74
89
  * @param name [optional] The name of the game object
75
90
  * @returns The added game object
76
- * @returns
77
91
  */
78
92
  protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions | string, name?: string): T;
79
93
  /**
@@ -110,6 +124,8 @@ export declare abstract class GameActor {
110
124
  * @param gameObject The game object to destory
111
125
  */
112
126
  protected destroyGameObject(gameObject: GameObject): void;
127
+ /** @private */
113
128
  protected abstract _destroy(): void;
129
+ /** @private */
114
130
  protected abstract _stopGame(): void;
115
131
  }
@@ -1,18 +1,61 @@
1
1
  import { BroadPhaseMethods, CollisionMatrix, CollisionMethods } from "angry-pixel-2d-physics";
2
2
  import { Rectangle, Vector2 } from "angry-pixel-math";
3
+ /**
4
+ * Game configuration options
5
+ * @public
6
+ * @category Core
7
+ * @example
8
+ * ```js
9
+ * const gameConfig = {
10
+ * containerNode: document.getElementById("app"),
11
+ * gameWidth: 1920,
12
+ * gameHeight: 1080,
13
+ * debugEnabled: false,
14
+ * canvasColor: "#000000",
15
+ * physicsFramerate: 180,
16
+ * headless: false,
17
+ * spriteDefaultScale: new Vector2(1, 1),
18
+ * collisions: {
19
+ * collisionMatrix: [
20
+ * ["layer1", "layer2"],
21
+ * ["layer1", "layer3"],
22
+ * ],
23
+ * collisionMethod: CollisionMethods.SAT,
24
+ * collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
25
+ * collisionArea: new Rectangle(-960, -540, 1920, 1080),
26
+ * }
27
+ * };
28
+ * ```
29
+ */
3
30
  export interface GameConfig {
4
- containerNode?: HTMLElement | null;
31
+ /** HTML element where the game will be created */
32
+ containerNode?: HTMLElement;
33
+ /** Game width */
5
34
  gameWidth?: number;
35
+ /** Game height */
6
36
  gameHeight?: number;
37
+ /** Enables the debug mode */
7
38
  debugEnabled?: boolean;
39
+ /** Background color of canvas */
8
40
  canvasColor?: string;
41
+ /** Framerate for physics execution. The allowed values are 60, 120, 180, 240.
42
+ * The higher the framerate, the more accurate the physics will be, but it will consume more processor resources.
43
+ * Default value is 180.
44
+ */
9
45
  physicsFramerate?: number;
10
- spriteDefaultScale?: Vector2 | null;
46
+ /** Define a general scaling for all sprites. It can be overwritten individually on each sprite */
47
+ spriteDefaultScale?: Vector2;
48
+ /** Enable Headless mode. The input and rendering functions are turned off. Ideal for game server development */
11
49
  headless?: boolean;
50
+ /** Collision configuration options */
12
51
  collisions?: {
52
+ /** Collision detection method: CollisionMethods.SAT or CollisionMethods.ABB. Default value is CollisionMethods.SAT */
13
53
  collisionMethod?: CollisionMethods;
54
+ /** Define a fixed area */
14
55
  collisionArea?: Rectangle;
56
+ /** Define a fixed rectangular area for collision detection */
15
57
  collisionMatrix?: CollisionMatrix;
58
+ /** Collision broad phase method: BroadPhaseMethods.QuadTree or BroadPhaseMethods.SpartialGrid. Default values is BroadPhaseMethods.SpartialGrid */
16
59
  collisionBroadPhaseMethod?: BroadPhaseMethods;
17
60
  };
18
61
  }