@byloth/core 2.0.0 → 2.0.1

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.
@@ -75,10 +75,15 @@ export default class Countdown extends GameLoop
75
75
  /**
76
76
  * Initializes a new instance of the {@link Countdown} class.
77
77
  *
78
+ * ---
79
+ *
80
+ * @example
78
81
  * ```ts
79
82
  * const countdown = new Countdown(10_000);
80
83
  * ```
81
84
  *
85
+ * ---
86
+ *
82
87
  * @param duration
83
88
  * The total duration of the countdown in milliseconds.
84
89
  *
@@ -140,11 +145,16 @@ export default class Countdown extends GameLoop
140
145
  *
141
146
  * If the countdown is already running, a {@link RuntimeException} will be thrown.
142
147
  *
148
+ * ---
149
+ *
150
+ * @example
143
151
  * ```ts
144
152
  * countdown.onStart(() => { [...] }); // This callback will be executed.
145
153
  * countdown.start();
146
154
  * ```
147
155
  *
156
+ * ---
157
+ *
148
158
  * @param remainingTime
149
159
  * The remaining time to set as default when the countdown starts.
150
160
  * Default is the {@link Countdown.duration} itself.
@@ -169,11 +179,16 @@ export default class Countdown extends GameLoop
169
179
  *
170
180
  * If the countdown hasn't yet started, a {@link RuntimeException} will be thrown.
171
181
  *
182
+ * ---
183
+ *
184
+ * @example
172
185
  * ```ts
173
186
  * countdown.onStop(() => { [...] }); // This callback will be executed.
174
187
  * countdown.stop();
175
188
  * ```
176
189
  *
190
+ * ---
191
+ *
177
192
  * @param reason
178
193
  * The reason why the countdown has stopped.
179
194
  *
@@ -194,11 +209,16 @@ export default class Countdown extends GameLoop
194
209
  /**
195
210
  * Subscribes to the `expire` event of the countdown.
196
211
  *
212
+ * ---
213
+ *
214
+ * @example
197
215
  * ```ts
198
216
  * countdown.onExpire(() => { [...] }); // This callback will be executed once the countdown has expired.
199
217
  * countdown.start();
200
218
  * ```
201
219
  *
220
+ * ---
221
+ *
202
222
  * @param callback The callback that will be executed when the countdown expires.
203
223
  *
204
224
  * @returns A function that can be used to unsubscribe from the event.
@@ -211,11 +231,16 @@ export default class Countdown extends GameLoop
211
231
  /**
212
232
  * Subscribes to the `tick` event of the countdown.
213
233
  *
234
+ * ---
235
+ *
236
+ * @example
214
237
  * ```ts
215
238
  * countdown.onTick((remainingTime) => { [...] }); // This callback will be executed.
216
239
  * countdown.start();
217
240
  * ```
218
241
  *
242
+ * ---
243
+ *
219
244
  * @param callback The callback that will be executed when the countdown ticks.
220
245
  * @param tickStep
221
246
  * The minimum time in milliseconds that must pass from the previous execution of the callback to the next one.
@@ -116,10 +116,15 @@ export default class GameLoop
116
116
  /**
117
117
  * Initializes a new instance of the {@link GameLoop} class.
118
118
  *
119
+ * ---
120
+ *
121
+ * @example
119
122
  * ```ts
120
123
  * const loop = new GameLoop((elapsedTime: number) => { [...] });
121
124
  * ```
122
125
  *
126
+ * ---
127
+ *
123
128
  * @param callback The function that will be executed at each iteration of the game loop.
124
129
  * @param msIfNotBrowser
125
130
  * The interval in milliseconds that will be used if the current environment isn't a browser. Default is `40`.
@@ -164,11 +169,16 @@ export default class GameLoop
164
169
  *
165
170
  * If the game loop is already running, a {@link RuntimeException} will be thrown.
166
171
  *
172
+ * ---
173
+ *
174
+ * @example
167
175
  * ```ts
168
176
  * loop.onStart(() => { [...] }); // This callback will be executed.
169
177
  * loop.start();
170
178
  * ```
171
179
  *
180
+ * ---
181
+ *
172
182
  * @param elapsedTime The elapsed time to set as default when the game loop starts. Default is `0`.
173
183
  */
174
184
  public start(elapsedTime = 0): void
@@ -187,6 +197,9 @@ export default class GameLoop
187
197
  *
188
198
  * If the game loop hasn't yet started, a {@link RuntimeException} will be thrown.
189
199
  *
200
+ * ---
201
+ *
202
+ * @example
190
203
  * ```ts
191
204
  * loop.onStop(() => { [...] }); // This callback will be executed.
192
205
  * loop.stop();
@@ -210,10 +223,15 @@ export default class GameLoop
210
223
  /**
211
224
  * Subscribes to the `start` event of the game loop.
212
225
  *
226
+ * ---
227
+ *
228
+ * @example
213
229
  * ```ts
214
230
  * loop.onStart(() => { console.log("The game loop has started."); });
215
231
  * ```
216
232
  *
233
+ * ---
234
+ *
217
235
  * @param callback The function that will be executed when the game loop starts.
218
236
  *
219
237
  * @returns A function that can be used to unsubscribe from the event.
@@ -226,10 +244,15 @@ export default class GameLoop
226
244
  /**
227
245
  * Subscribes to the `stop` event of the game loop.
228
246
  *
247
+ * ---
248
+ *
249
+ * @example
229
250
  * ```ts
230
251
  * loop.onStop(() => { console.log("The game loop has stopped."); });
231
252
  * ```
232
253
  *
254
+ * ---
255
+ *
233
256
  * @param callback The function that will be executed when the game loop stops.
234
257
  *
235
258
  * @returns A function that can be used to unsubscribe from the event.
@@ -13,6 +13,9 @@ export default class Curve
13
13
  * Generates a given number of values following a linear curve.
14
14
  * The values are equally spaced and normalized between 0 and 1.
15
15
  *
16
+ * ---
17
+ *
18
+ * @example
16
19
  * ```ts
17
20
  * for (const value of Curve.Linear(5))
18
21
  * {
@@ -20,6 +23,8 @@ export default class Curve
20
23
  * }
21
24
  * ```
22
25
  *
26
+ * ---
27
+ *
23
28
  * @param values The number of values to generate.
24
29
  *
25
30
  * @returns A {@link SmartIterator} object that generates the values following a linear curve.
@@ -38,6 +43,9 @@ export default class Curve
38
43
  * Generates a given number of values following an exponential curve.
39
44
  * The values are equally spaced and normalized between 0 and 1.
40
45
  *
46
+ * ---
47
+ *
48
+ * @example
41
49
  * ```ts
42
50
  * for (const value of Curve.Exponential(6))
43
51
  * {
@@ -45,6 +53,8 @@ export default class Curve
45
53
  * }
46
54
  * ```
47
55
  *
56
+ * ---
57
+ *
48
58
  * @param values The number of values to generate.
49
59
  * @param base
50
60
  * The base of the exponential curve. Default is `2`.
@@ -12,6 +12,9 @@ export default class Random
12
12
  /**
13
13
  * Generates a random boolean value.
14
14
  *
15
+ * ---
16
+ *
17
+ * @example
15
18
  * ```ts
16
19
  * if (Random.Boolean())
17
20
  * {
@@ -19,6 +22,8 @@ export default class Random
19
22
  * }
20
23
  * ```
21
24
  *
25
+ * ---
26
+ *
22
27
  * @param ratio
23
28
  * The probability of generating `true`.
24
29
  *
@@ -34,10 +39,15 @@ export default class Random
34
39
  /**
35
40
  * Generates a random integer value between `0` (included) and `max` (excluded).
36
41
  *
42
+ * ---
43
+ *
44
+ * @example
37
45
  * ```ts
38
46
  * Random.Integer(5); // 0, 1, 2, 3, 4
39
47
  * ```
40
48
  *
49
+ * ---
50
+ *
41
51
  * @param max The maximum value (excluded).
42
52
  *
43
53
  * @returns A random integer value.
@@ -47,10 +57,15 @@ export default class Random
47
57
  /**
48
58
  * Generates a random integer value between `min` (included) and `max` (excluded).
49
59
  *
60
+ * ---
61
+ *
62
+ * @example
50
63
  * ```ts
51
64
  * Random.Integer(2, 7); // 2, 3, 4, 5, 6
52
65
  * ```
53
66
  *
67
+ * ---
68
+ *
54
69
  * @param min The minimum value (included).
55
70
  * @param max The maximum value (excluded).
56
71
  *
@@ -67,10 +82,15 @@ export default class Random
67
82
  /**
68
83
  * Generates a random decimal value between `0` (included) and `1` (excluded).
69
84
  *
85
+ * ---
86
+ *
87
+ * @example
70
88
  * ```ts
71
89
  * Random.Decimal(); // 0.123456789
72
90
  * ```
73
91
  *
92
+ * ---
93
+ *
74
94
  * @returns A random decimal value.
75
95
  */
76
96
  public static Decimal(): number;
@@ -78,10 +98,15 @@ export default class Random
78
98
  /**
79
99
  * Generates a random decimal value between `0` (included) and `max` (excluded).
80
100
  *
101
+ * ---
102
+ *
103
+ * @example
81
104
  * ```ts
82
105
  * Random.Decimal(5); // 2.3456789
83
106
  * ```
84
107
  *
108
+ * ---
109
+ *
85
110
  * @param max The maximum value (excluded).
86
111
  *
87
112
  * @returns A random decimal value.
@@ -91,10 +116,15 @@ export default class Random
91
116
  /**
92
117
  * Generates a random decimal value between `min` (included) and `max` (excluded).
93
118
  *
119
+ * ---
120
+ *
121
+ * @example
94
122
  * ```ts
95
123
  * Random.Decimal(2, 7); // 4.56789
96
124
  * ```
97
125
  *
126
+ * ---
127
+ *
98
128
  * @param min The minimum value (included).
99
129
  * @param max The maximum value (excluded).
100
130
  *