emeraldengine 2.0.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.
Files changed (73) hide show
  1. package/README.md +968 -0
  2. package/dist/types/imports/BitmapText.d.ts +79 -0
  3. package/dist/types/imports/Color.d.ts +17 -0
  4. package/dist/types/imports/Drawable.d.ts +157 -0
  5. package/dist/types/imports/Emerald.d.ts +73 -0
  6. package/dist/types/imports/FPSCounter.d.ts +19 -0
  7. package/dist/types/imports/GLUtils.d.ts +6 -0
  8. package/dist/types/imports/Instance.d.ts +87 -0
  9. package/dist/types/imports/InstancedTexture.d.ts +230 -0
  10. package/dist/types/imports/Physics.d.ts +139 -0
  11. package/dist/types/imports/Scene.d.ts +39 -0
  12. package/dist/types/imports/Shaders.d.ts +4 -0
  13. package/dist/types/imports/Shapes.d.ts +25 -0
  14. package/dist/types/imports/Storage.d.ts +46 -0
  15. package/dist/types/imports/Texture.d.ts +19 -0
  16. package/dist/types/imports/Time.d.ts +22 -0
  17. package/dist/types/imports/Transform.d.ts +41 -0
  18. package/dist/types/imports/components/BoxCollider.d.ts +41 -0
  19. package/dist/types/imports/components/BoxColliderDebug.d.ts +19 -0
  20. package/dist/types/imports/components/CircleCollider.d.ts +39 -0
  21. package/dist/types/imports/components/CircleColliderDebug.d.ts +19 -0
  22. package/dist/types/imports/components/Collider.d.ts +53 -0
  23. package/dist/types/imports/components/GameObject.d.ts +72 -0
  24. package/dist/types/imports/components/RigidBody.d.ts +104 -0
  25. package/dist/types/imports/lights/DirectionalLight.d.ts +26 -0
  26. package/dist/types/imports/lights/PointLight.d.ts +18 -0
  27. package/dist/types/imports/managers/AudioManager.d.ts +60 -0
  28. package/dist/types/imports/managers/CameraManager.d.ts +35 -0
  29. package/dist/types/imports/managers/EventManager.d.ts +187 -0
  30. package/dist/types/imports/managers/GLManager.d.ts +47 -0
  31. package/dist/types/imports/managers/IDManager.d.ts +21 -0
  32. package/dist/types/imports/managers/SceneManager.d.ts +22 -0
  33. package/dist/types/imports/particlesystem/Particle.d.ts +42 -0
  34. package/dist/types/imports/particlesystem/ParticleSettings.d.ts +49 -0
  35. package/dist/types/imports/particlesystem/Particles.d.ts +71 -0
  36. package/dist/types/index.d.ts +32 -0
  37. package/imports/BitmapText.js +245 -0
  38. package/imports/Color.js +18 -0
  39. package/imports/Drawable.js +550 -0
  40. package/imports/Emerald.js +459 -0
  41. package/imports/FPSCounter.js +43 -0
  42. package/imports/GLUtils.js +67 -0
  43. package/imports/Instance.js +187 -0
  44. package/imports/InstancedTexture.js +856 -0
  45. package/imports/Physics.js +242 -0
  46. package/imports/Scene.js +79 -0
  47. package/imports/Shaders.js +165 -0
  48. package/imports/Shapes.js +129 -0
  49. package/imports/Storage.js +63 -0
  50. package/imports/Texture.js +67 -0
  51. package/imports/Time.js +28 -0
  52. package/imports/Transform.js +59 -0
  53. package/imports/components/BoxCollider.js +67 -0
  54. package/imports/components/BoxColliderDebug.js +38 -0
  55. package/imports/components/CircleCollider.js +67 -0
  56. package/imports/components/CircleColliderDebug.js +36 -0
  57. package/imports/components/Collider.js +51 -0
  58. package/imports/components/GameObject.js +160 -0
  59. package/imports/components/RigidBody.js +169 -0
  60. package/imports/lights/DirectionalLight.js +68 -0
  61. package/imports/lights/PointLight.js +17 -0
  62. package/imports/managers/AudioManager.js +146 -0
  63. package/imports/managers/CameraManager.js +60 -0
  64. package/imports/managers/EventManager.js +479 -0
  65. package/imports/managers/GLManager.js +65 -0
  66. package/imports/managers/IDManager.js +32 -0
  67. package/imports/managers/SceneManager.js +27 -0
  68. package/imports/managers/ShaderManager.js +133 -0
  69. package/imports/particlesystem/Particle.js +75 -0
  70. package/imports/particlesystem/ParticleSettings.js +49 -0
  71. package/imports/particlesystem/Particles.js +226 -0
  72. package/index.js +67 -0
  73. package/package.json +38 -0
@@ -0,0 +1,104 @@
1
+ import * as planck from "planck";
2
+ import { Physics, Vector2 } from "../Physics";
3
+ import Collider from "./Collider";
4
+ import GameObject from "./GameObject";
5
+ /**
6
+ * @class RigidBody
7
+ * @param {Physics} physics - The physics engine
8
+ * @param {string | "static" | "dynamic" | "kinematic"} type - The type of rigidbody
9
+ * @param {Vector2} position - The position of the rigidbody
10
+ * @param {boolean} fixedRotation - Whether the rigidbody is fixed rotation
11
+ * @param {GameObject} parentObject - The parent object of the rigidbody
12
+ * @param {Vector2} offset - The offset of the rigidbody
13
+ */
14
+ declare class RigidBody {
15
+ physics: Physics;
16
+ offset: Vector2;
17
+ type: string;
18
+ body: planck.Body;
19
+ parentObject: GameObject | null;
20
+ position: Vector2;
21
+ collider: Collider | null;
22
+ id: string;
23
+ name: string;
24
+ constructor(physics: Physics, type: string, position: Vector2, fixedRotation: boolean, parentObject?: GameObject | null, offset?: Vector2);
25
+ /**
26
+ * @method updatePosition
27
+ * @description Updates the position of the rigidbody
28
+ * @param {Vector2} position - The new position
29
+ */
30
+ updatePosition(position: Vector2): void;
31
+ /**
32
+ * @method getOffset
33
+ * @description Returns the offset of the rigidbody
34
+ * @returns {Vector2} - The offset of the rigidbody
35
+ */
36
+ getOffset(): Vector2;
37
+ /**
38
+ * @method setCollider
39
+ * @description Sets the collider of the rigidbody
40
+ * @param {Collider} collider - The collider to set
41
+ */
42
+ setCollider(collider: Collider): void;
43
+ /**
44
+ * @method setRotation
45
+ * @description Sets the rotation of the rigidbody
46
+ * @param {number} rotation - The new rotation
47
+ */
48
+ setRotation(rotation: number): void;
49
+ /**
50
+ * @method getPosition
51
+ * @description Returns the position of the rigidbody
52
+ * @returns {Vector2} - The position of the rigidbody
53
+ */
54
+ getPosition(): Vector2;
55
+ /**
56
+ * @method getAngle
57
+ * @description Returns the angle of the rigidbody
58
+ * @returns {number} - The angle of the rigidbody
59
+ */
60
+ getAngle(): number;
61
+ /**
62
+ * @method getCollider
63
+ * @description Returns the collider of the rigidbody
64
+ * @returns {Collider} - The collider of the rigidbody
65
+ */
66
+ getCollider(): Collider | null;
67
+ /**
68
+ * @method getBody
69
+ * @description Returns the body of the rigidbody
70
+ * @returns {planck.Body} - The body of the rigidbody
71
+ */
72
+ getBody(): planck.Body;
73
+ /**
74
+ * @method getPhysics
75
+ * @description Returns the physics engine of the rigidbody
76
+ * @returns {Physics} - The physics engine of the rigidbody
77
+ */
78
+ getPhysics(): Physics;
79
+ /**
80
+ * @method destroy
81
+ * @description Destroys the rigidbody
82
+ */
83
+ destroy(): void;
84
+ /**
85
+ * @method detachCollider
86
+ * @description Detaches a collider from the rigidbody
87
+ * @param {Collider} collider - The collider to detach
88
+ */
89
+ detachCollider(collider: Collider): void;
90
+ /**
91
+ * @method setParent
92
+ * @description Sets the parent object of the rigidbody
93
+ * @param {GameObject} parent - The parent object to set
94
+ */
95
+ setParent(parent: GameObject): void;
96
+ /**
97
+ * @method getType
98
+ * @description Returns the type of the rigidbody
99
+ * @returns {string | "static" | "dynamic" | "kinematic"} - The type of the rigidbody
100
+ */
101
+ getType(): string;
102
+ }
103
+ export default RigidBody;
104
+ //# sourceMappingURL=RigidBody.d.ts.map
@@ -0,0 +1,26 @@
1
+ import Color from "../Color";
2
+ import { Vector2 } from "../Physics";
3
+ /**
4
+ * @class DirectionalLight
5
+ * @param {Vector2} position - The position of the light
6
+ * @param {Vector2} direction - The direction of the light
7
+ * @param {Color} color - The color of the light
8
+ * @param {number} intensity - The intensity of the light
9
+ * @param {number} width - The width of the light
10
+ */
11
+ declare class DirectionalLight {
12
+ position: Vector2;
13
+ direction: Vector2;
14
+ color: Color;
15
+ intensity: number;
16
+ width: number;
17
+ constructor(position: Vector2, direction: Vector2, color: Color, intensity: number, width: number);
18
+ /**
19
+ * Calculate the light intensity at a given point
20
+ * @param {Vector2} point - The point to calculate intensity for
21
+ * @returns {number} - Light intensity (0-1)
22
+ */
23
+ getIntensityAtPoint(point: Vector2): number;
24
+ }
25
+ export default DirectionalLight;
26
+ //# sourceMappingURL=DirectionalLight.d.ts.map
@@ -0,0 +1,18 @@
1
+ import Color from "../Color";
2
+ import { Vector2 } from "../Physics";
3
+ /**
4
+ * @class PointLight
5
+ * @param {Vector2} position - The position of the light
6
+ * @param {Color} color - The color of the light
7
+ * @param {number} intensity - The intensity of the light
8
+ * @param {number} radius - The radius of the light
9
+ */
10
+ declare class PointLight {
11
+ position: Vector2;
12
+ color: Color;
13
+ intensity: number;
14
+ radius: number;
15
+ constructor(position: Vector2, color: Color, intensity: number, radius: number);
16
+ }
17
+ export default PointLight;
18
+ //# sourceMappingURL=PointLight.d.ts.map
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @class AudioManager
3
+ * @description Manages the audio for the game
4
+ */
5
+ declare class AudioManager {
6
+ sounds: Map<string, {
7
+ audio: HTMLAudioElement;
8
+ id: string;
9
+ playPromise: Promise<void> | null;
10
+ }>;
11
+ constructor();
12
+ /**
13
+ * @method add
14
+ * @description Adds an audio file to the manager
15
+ * @param {string} path - The path to the audio file
16
+ * @param {string} name - The name of the audio file
17
+ */
18
+ add(path: string, name: string): boolean;
19
+ /**
20
+ * @method remove
21
+ * @description Removes an audio file from the manager
22
+ * @param {string} name - The name of the audio file
23
+ */
24
+ remove(name: string): boolean;
25
+ /**
26
+ * @method play
27
+ * @description Plays an audio file
28
+ * @param {string} name - The name of the audio file
29
+ */
30
+ play(name: string): Promise<boolean>;
31
+ /**
32
+ * @method stop
33
+ * @description Stops an audio file
34
+ * @param {string} name - The name of the audio file
35
+ */
36
+ stop(name: string): Promise<boolean>;
37
+ /**
38
+ * @method stopAll
39
+ * @description Stops all audio files
40
+ */
41
+ stopAll(): Promise<void>;
42
+ /**
43
+ * @method playExclusive
44
+ * @description Plays an audio file after stopping all other audio files
45
+ * @param {string} name - The name of the audio file
46
+ */
47
+ playExclusive(name: string): Promise<boolean>;
48
+ /**
49
+ * @method getSound
50
+ * @description Returns an audio file from the manager
51
+ * @param {string} name - The name of the audio file
52
+ */
53
+ getSound(name: string): {
54
+ audio: HTMLAudioElement;
55
+ id: string;
56
+ playPromise: Promise<void> | null;
57
+ } | undefined;
58
+ }
59
+ export default AudioManager;
60
+ //# sourceMappingURL=AudioManager.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { Vector2 } from "../Physics";
2
+ /**
3
+ * @class CameraManager
4
+ * @description Manages the camera for the game
5
+ */
6
+ declare class CameraManager {
7
+ static camera: any;
8
+ static lastPosition: Vector2 | null;
9
+ /**
10
+ * @method setLastPosition
11
+ * @description Sets the last position of the camera
12
+ * @param {Vector2} position - The position to set
13
+ */
14
+ static setLastPosition(position: Vector2): void;
15
+ /**
16
+ * @method getLastPosition
17
+ * @description Returns the last position of the camera
18
+ * @returns {Vector2} - The last position of the camera
19
+ */
20
+ static getLastPosition(): Vector2 | null;
21
+ /**
22
+ * @method setCamera
23
+ * @description Sets the camera for the game
24
+ * @param {Camera} camera - The camera to set
25
+ */
26
+ static setCamera(camera: any): void;
27
+ /**
28
+ * @method getCamera
29
+ * @description Returns the camera for the game
30
+ * @returns {Camera} - The camera for the game
31
+ */
32
+ static getCamera(): any | null;
33
+ }
34
+ export default CameraManager;
35
+ //# sourceMappingURL=CameraManager.d.ts.map
@@ -0,0 +1,187 @@
1
+ import Scene from "../Scene";
2
+ import GameObject from "../components/GameObject";
3
+ import Instance from "../Instance";
4
+ /**
5
+ * @class EventManager
6
+ * @description Manages the events for the game
7
+ * @param {HTMLCanvasElement} canvas - The canvas element
8
+ * @param {Scene} scene - The scene
9
+ * @param {Camera} camera - The camera
10
+ */
11
+ declare class EventManager {
12
+ scene: Scene;
13
+ camera: any;
14
+ canvas: HTMLCanvasElement;
15
+ keyDownListeners: Map<string, Set<Function>>;
16
+ keyUpListeners: Map<string, Set<Function>>;
17
+ clickListeners: Map<string, Set<Function>>;
18
+ canvasWidth: number;
19
+ canvasHeight: number;
20
+ hoverListeners: Map<string, {
21
+ enter: Set<Function>;
22
+ leave: Set<Function>;
23
+ }>;
24
+ lastHoveredObject: GameObject | null;
25
+ lastHoveredInstance: Instance | null;
26
+ pressedKeys: Map<string, boolean>;
27
+ mousePosition: {
28
+ x: number;
29
+ y: number;
30
+ };
31
+ isDragging: boolean;
32
+ dragStartX: number;
33
+ dragStartY: number;
34
+ initialCameraX: number;
35
+ initialCameraY: number;
36
+ cameraWasMoved: boolean;
37
+ boundHandleMouseMove: (event: MouseEvent) => void;
38
+ boundHandleKeyDown: (event: KeyboardEvent) => void;
39
+ boundHandleKeyUp: (event: KeyboardEvent) => void;
40
+ boundHandleClick: (event: MouseEvent) => void;
41
+ boundHandleMouseDown: (event: MouseEvent) => void;
42
+ boundHandleMouseUp: (event: MouseEvent) => void;
43
+ constructor(canvas: HTMLCanvasElement, scene: Scene, camera: any);
44
+ /**
45
+ * @method addKeyDown
46
+ * @description Adds a key down event listener
47
+ * @param {string} key - The key to listen for
48
+ * @param {function} func - The function to call when the key is pressed
49
+ */
50
+ addKeyDown(key: string, func: Function): void;
51
+ /**
52
+ * @method addKeyUp
53
+ * @description Adds a key up event listener
54
+ * @param {string} key - The key to listen for
55
+ * @param {function} func - The function to call when the key is released
56
+ */
57
+ addKeyUp(key: string, func: Function): void;
58
+ /**
59
+ * @method removeKeyDown
60
+ * @description Removes a key down event listener
61
+ * @param {string} key - The key to remove the listener for
62
+ * @param {function} func - The function to remove
63
+ */
64
+ removeKeyDown(key: string, func: Function): void;
65
+ /**
66
+ * @method removeKeyUp
67
+ * @description Removes a key up event listener
68
+ * @param {string} key - The key to remove the listener for
69
+ * @param {function} func - The function to remove
70
+ */
71
+ removeKeyUp(key: string, func: Function): void;
72
+ /**
73
+ * @method handleKeyDown
74
+ * @description Handles a key down event
75
+ * @param {KeyboardEvent} event - The keyboard event
76
+ */
77
+ handleKeyDown(event: KeyboardEvent): void;
78
+ /**
79
+ * @method handleKeyUp
80
+ * @description Handles a key up event
81
+ * @param {KeyboardEvent} event - The keyboard event
82
+ */
83
+ handleKeyUp(event: KeyboardEvent): void;
84
+ /**
85
+ * @method isKeyPressed
86
+ * @description Checks if a key is pressed
87
+ * @param {string} key - The key to check
88
+ * @returns {boolean} - True if the key is pressed
89
+ */
90
+ isKeyPressed(key: string): boolean;
91
+ /**
92
+ * @method addClickEvent
93
+ * @description Adds a click event listener
94
+ * @param {GameObject} object - The object to listen for
95
+ * @param {function} func - The function to call when the object is clicked
96
+ */
97
+ addClickEvent(object: GameObject, func: Function): void;
98
+ /**
99
+ * @method handleClick
100
+ * @description Handles a click event
101
+ * @param {MouseEvent} event - The mouse event
102
+ */
103
+ handleClick(event: MouseEvent): void;
104
+ /**
105
+ * @method removeClickEvent
106
+ * @description Removes a click event listener
107
+ * @param {GameObject} object - The object to remove the listener for
108
+ * @param {function} func - The function to remove
109
+ */
110
+ removeClickEvent(object: GameObject, func: Function): void;
111
+ /**
112
+ * @method isPointInObject
113
+ * @description Checks if a point is in an object
114
+ * @param {number} x - The x coordinate of the point
115
+ * @param {number} y - The y coordinate of the point
116
+ * @param {GameObject} object - The object to check
117
+ * @returns {boolean} - True if the point is in the object
118
+ */
119
+ isPointInObject(x: number, y: number, object: GameObject): boolean;
120
+ /**
121
+ * @method addHoverEvent
122
+ * @description Adds a hover event listener
123
+ * @param {GameObject} object - The object to listen for
124
+ * @param {function} enterFunc - The function to call when the object is hovered
125
+ * @param {function} leaveFunc - The function to call when the object is no longer hovered
126
+ */
127
+ addHoverEvent(object: GameObject, enterFunc: Function, leaveFunc: Function): void;
128
+ /**
129
+ * @method removeHoverEvent
130
+ * @description Removes a hover event listener
131
+ * @param {GameObject} object - The object to remove the listener for
132
+ * @param {function} enterFunc - The function to remove
133
+ * @param {function} leaveFunc - The function to remove
134
+ */
135
+ removeHoverEvent(object: GameObject, enterFunc: Function, leaveFunc: Function): void;
136
+ /**
137
+ * @method handleMouseDown
138
+ * @description Handles a mouse down event
139
+ * @param {MouseEvent} event - The mouse event
140
+ */
141
+ handleMouseDown(event: MouseEvent): void;
142
+ /**
143
+ * @method handleMouseUp
144
+ * @description Handles a mouse up event
145
+ * @param {MouseEvent} event - The mouse event
146
+ */
147
+ handleMouseUp(event: MouseEvent): void;
148
+ /**
149
+ * @method handleMouseMove
150
+ * @description Handles a mouse move event
151
+ * @param {MouseEvent} event - The mouse event
152
+ */
153
+ handleMouseMove(event: MouseEvent): void;
154
+ /**
155
+ * @method getMousePosition
156
+ * @description Returns the mouse position
157
+ * @returns {Object} - The mouse position
158
+ */
159
+ getMousePosition(): {
160
+ x: number;
161
+ y: number;
162
+ };
163
+ /**
164
+ * @method wasCameraMoved
165
+ * @description Checks if the camera was moved
166
+ * @returns {boolean} - True if the camera was moved
167
+ */
168
+ wasCameraMoved(): boolean;
169
+ /**
170
+ * @method resetCameraMoved
171
+ * @description Resets the camera moved flag
172
+ */
173
+ resetCameraMoved(): void;
174
+ /**
175
+ * @method changeScene
176
+ * @description Changes the scene
177
+ * @param {Scene} scene - The scene to change to
178
+ */
179
+ changeScene(scene: Scene): void;
180
+ /**
181
+ * @method clean
182
+ * @description Cleans up the event manager
183
+ */
184
+ clean(): void;
185
+ }
186
+ export default EventManager;
187
+ //# sourceMappingURL=EventManager.d.ts.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @class GLManager
3
+ * @description Manages the WebGL context for the game
4
+ */
5
+ declare class GLManager {
6
+ static gl: WebGL2RenderingContext | null;
7
+ static programInfo: any | null;
8
+ static canvas: HTMLCanvasElement | null;
9
+ /**
10
+ * @method setGL
11
+ * @description Sets the WebGL context
12
+ * @param {WebGLRenderingContext} gl - The WebGL context
13
+ */
14
+ static setGL(gl: WebGL2RenderingContext): void;
15
+ /**
16
+ * @method setProgramInfo
17
+ * @description Sets the program info
18
+ * @param {Object} programInfo - The program info
19
+ */
20
+ static setProgramInfo(programInfo: any): void;
21
+ /**
22
+ * @method setCanvas
23
+ * @description Sets the canvas
24
+ * @param {HTMLCanvasElement} canvas - The canvas
25
+ */
26
+ static setCanvas(canvas: HTMLCanvasElement): void;
27
+ /**
28
+ * @method getGL
29
+ * @description Returns the WebGL context
30
+ * @returns {WebGLRenderingContext} - The WebGL context
31
+ */
32
+ static getGL(): WebGL2RenderingContext | null;
33
+ /**
34
+ * @method getProgramInfo
35
+ * @description Returns the program info
36
+ * @returns {Object} - The program info
37
+ */
38
+ static getProgramInfo(): any | null;
39
+ /**
40
+ * @method getCanvas
41
+ * @description Returns the canvas
42
+ * @returns {HTMLCanvasElement} - The canvas
43
+ */
44
+ static getCanvas(): HTMLCanvasElement | null;
45
+ }
46
+ export default GLManager;
47
+ //# sourceMappingURL=GLManager.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @class IDManager
3
+ * @description Manages the IDs for the game
4
+ */
5
+ declare class IDManager {
6
+ static existingIDs: Set<string>;
7
+ /**
8
+ * @method generateID
9
+ * @description Generates a random ID
10
+ * @returns {string} - The random ID
11
+ */
12
+ static generateID(): string;
13
+ /**
14
+ * @method generateUniqueID
15
+ * @description Generates a unique ID
16
+ * @returns {string} - The unique ID
17
+ */
18
+ static generateUniqueID(): string;
19
+ }
20
+ export default IDManager;
21
+ //# sourceMappingURL=IDManager.d.ts.map
@@ -0,0 +1,22 @@
1
+ import Scene from "../Scene";
2
+ /**
3
+ * @class SceneManager
4
+ * @description Manages the scene for the game
5
+ */
6
+ declare class SceneManager {
7
+ static scene: Scene | null;
8
+ /**
9
+ * @method setScene
10
+ * @description Sets the scene
11
+ * @param {Scene} scene - The scene to set
12
+ */
13
+ static setScene(scene: Scene): void;
14
+ /**
15
+ * @method getScene
16
+ * @description Returns the scene
17
+ * @returns {Scene} - The scene
18
+ */
19
+ static getScene(): Scene | null;
20
+ }
21
+ export default SceneManager;
22
+ //# sourceMappingURL=SceneManager.d.ts.map
@@ -0,0 +1,42 @@
1
+ import Instance from "../Instance";
2
+ import InstancedTexture from "../InstancedTexture";
3
+ import { Vector2, Vector3 } from "../Physics";
4
+ import ParticleSettings from "./ParticleSettings";
5
+ /**
6
+ * @class Particle
7
+ * @description Represents a particle in the particle system
8
+ * @param {InstancedTexture} instancedTexture - The instanced texture
9
+ * @param {Vector3} position - The position of the particle
10
+ * @param {number} rotation - The rotation of the particle
11
+ * @param {Vector2} scale - The scale of the particle
12
+ * @param {ParticleSettings} settings - The settings for the particle
13
+ */
14
+ declare class Particle {
15
+ settings: ParticleSettings;
16
+ lifetime: number;
17
+ age: number;
18
+ velocity: Vector2;
19
+ gravity: Vector2;
20
+ instance: Instance;
21
+ instancedTexture: InstancedTexture;
22
+ constructor(instancedTexture: InstancedTexture, position: Vector3, rotation: number, scale: Vector2, settings: ParticleSettings);
23
+ /**
24
+ * @method update
25
+ * @description Updates the particle
26
+ * @param {number} dt - The delta time
27
+ */
28
+ update(dt: number): void;
29
+ /**
30
+ * @method isAlive
31
+ * @description Checks if the particle is alive
32
+ * @returns {boolean} - True if the particle is alive
33
+ */
34
+ isAlive(): boolean;
35
+ /**
36
+ * @method destroy
37
+ * @description Destroys the particle
38
+ */
39
+ destroy(): void;
40
+ }
41
+ export default Particle;
42
+ //# sourceMappingURL=Particle.d.ts.map
@@ -0,0 +1,49 @@
1
+ import { Vector2 } from "../Physics";
2
+ interface ParticleSettingsConfig {
3
+ lifetime?: number;
4
+ velocity?: Vector2;
5
+ gravity?: Vector2;
6
+ amount?: number;
7
+ direction?: Vector2;
8
+ spread?: number;
9
+ emissionRate?: number;
10
+ frame?: number;
11
+ offset?: number;
12
+ rotation?: number;
13
+ scale?: Vector2;
14
+ animation?: any;
15
+ }
16
+ /**
17
+ * @class ParticleSettings
18
+ * @description Represents the settings for a particle system
19
+ * @param {number} lifetime - The lifetime of the particle
20
+ * @param {Vector2} velocity - The velocity of the particle
21
+ * @param {Vector2} gravity - The gravity of the particle
22
+ * @param {number} amount - The amount of particles
23
+ * @param {Vector2} direction - The direction of the particle
24
+ * @param {number} spread - The spread of the particle
25
+ * @param {number} emissionRate - The emission rate of the particle
26
+ * @param {number} frame - The frame of the particle
27
+ * @param {number} offset - The offset of the particle
28
+ * @param {number} rotation - The rotation of the particle
29
+ * @param {Vector2} scale - The scale of the particle
30
+ * @param {Array} animation - The animation of the particle
31
+ */
32
+ declare class ParticleSettings {
33
+ lifetime: number;
34
+ velocity: Vector2;
35
+ gravity: Vector2;
36
+ amount: number;
37
+ direction: Vector2;
38
+ spread: number;
39
+ emissionRate: number;
40
+ frame?: number;
41
+ offset?: number;
42
+ rotation?: number;
43
+ scale?: Vector2;
44
+ animation?: any;
45
+ constructor({ lifetime, velocity, gravity, amount, direction, spread, emissionRate, // particles per second
46
+ frame, offset, rotation, scale, animation }?: ParticleSettingsConfig);
47
+ }
48
+ export default ParticleSettings;
49
+ //# sourceMappingURL=ParticleSettings.d.ts.map
@@ -0,0 +1,71 @@
1
+ import GameObject from "../components/GameObject";
2
+ import InstancedTexture from "../InstancedTexture";
3
+ import { Vector2, Vector3 } from "../Physics";
4
+ import Particle from "./Particle";
5
+ import ParticleSettings from "./ParticleSettings";
6
+ /**
7
+ * @class Particles
8
+ * @description Represents a particle system
9
+ * @param {string} name - The name of the particle system
10
+ * @param {string} texturePath - The path to the texture
11
+ * @param {number} frameWidth - The width of the frame
12
+ * @param {number} frameHeight - The height of the frame
13
+ * @param {number} framesPerRow - The number of frames per row
14
+ * @param {number} totalFrames - The total number of frames
15
+ * @param {number} duration - The duration of the particle system
16
+ * @param {ParticleSettings} settings - The settings for the particle system
17
+ */
18
+ export default class Particles {
19
+ settings: ParticleSettings;
20
+ position: Vector3;
21
+ rotation: number;
22
+ scale: Vector2;
23
+ particles: Particle[];
24
+ duration: number;
25
+ offset: number;
26
+ elapsed: number;
27
+ active: boolean;
28
+ instanceCount: number;
29
+ emissionTimer: number;
30
+ emittedParticles: number;
31
+ stopped: boolean;
32
+ gameObject: GameObject;
33
+ instancedTexture: InstancedTexture;
34
+ lastEmitPosition: Vector3;
35
+ constructor(name: string, texturePath: string, frameWidth: number, frameHeight: number, framesPerRow: number, totalFrames: number, duration?: number, settings?: ParticleSettings | null);
36
+ /**
37
+ * @method play
38
+ * @description Plays the particle system
39
+ * @param {Vector3} newPosition - The position to play the particle system at
40
+ */
41
+ play(newPosition: Vector3): void;
42
+ /**
43
+ * @method emitParticles
44
+ * @description Emits particles
45
+ * @param {number} count - The number of particles to emit
46
+ * @param {Vector3} position - The position to emit the particles at
47
+ */
48
+ emitParticles(count: number, position: Vector3): void;
49
+ /**
50
+ * @method update
51
+ * @description Updates the particle system
52
+ * @param {number} deltaTime - The delta time
53
+ */
54
+ update(deltaTime: number): void;
55
+ /**
56
+ * @method stop
57
+ * @description Stops the particle system
58
+ */
59
+ stop(): void;
60
+ /**
61
+ * @method destroy
62
+ * @description Destroys the particle system
63
+ */
64
+ destroy(): void;
65
+ /**
66
+ * @method reset
67
+ * @description Resets the particle system
68
+ */
69
+ reset(): void;
70
+ }
71
+ //# sourceMappingURL=Particles.d.ts.map