@@ -313,16 +313,9 @@ <h2><a id="sound">Functions for Sound</a></h2>
313
313
// example: sfx([2,.05,598,.07,0,.19,0,1.32,9.9,-70,0,0,0,0,0,0,.3,.02,0,.04])
314
314
sfx(ZzFXparams: Array, volume = 1, pitch = 0, randomness = 0): AudioBufferSourceNode</ code > </ pre >
315
315
316
- < h2 > < a id ="math "> Functions for Math</ a > </ h2 >
317
-
318
- < pre > < code class ="language-typescript "> // check a collision between two rectangles
319
- // all arguments are required and must be numbers
320
- colrect(x1, y1, w1, h1, x2, y2, w2, h2): boolean
321
-
322
- // check a collision between two circles
323
- // all arguments are required and must be numbers
324
- colcirc(x1, y1, r1, x2, y2, r2): boolean
316
+ < h2 > < a id ="math "> Math</ a > </ h2 >
325
317
318
+ < pre > < code class ="language-typescript ">
326
319
// Generates a pseudo-random float between min (inclusive) and max (exclusive)
327
320
rand(min = 0, max = 1.0): number;
328
321
@@ -353,6 +346,19 @@ <h2><a id="math">Functions for Math</a></h2>
353
346
// example: clamp(-10, 0, 100) return 0
354
347
clamp(value: number, min: number, max: number): number
355
348
349
+ // Re-maps a number from one range to another.
350
+ // example: map(2, 0, 10, 0, 100) returns 20
351
+ map(val, l1, h1, l2, h2, withinBounds = false ): number
352
+
353
+ // Maps a number from one range to a value between 0 and 1.
354
+ // example: norm(50, 0, 100) returns 0.5
355
+ norm(val, start, stop): number
356
+
357
+ // Calculates the positive difference of two given numbers.
358
+ // example: diff(20, 30) return 10
359
+ // example: diff(-3, 3) return 6
360
+ diff(a, b): number
361
+
356
362
// Returns the sine of a number in radians.
357
363
sin(angle: number): number
358
364
@@ -411,6 +417,14 @@ <h2><a id="math">Functions for Math</a></h2>
411
417
// Returns 1 or -1, indicating the sign of a number.
412
418
// If the number is 0, it will returns 0.
413
419
sign(n: number): number
420
+
421
+ // check a collision between two rectangles
422
+ // all arguments are required and must be numbers
423
+ colrect(x1, y1, w1, h1, x2, y2, w2, h2): boolean
424
+
425
+ // check a collision between two circles
426
+ // all arguments are required and must be numbers
427
+ colcirc(x1, y1, r1, x2, y2, r2): boolean
414
428
</ code > </ pre >
415
429
416
430
< h2 > < a id ="globals "> Globals Variables</ a > </ h2 >
@@ -448,9 +462,12 @@ <h2><a id="globals">Globals Variables</a></h2>
448
462
// the tap/click Y position
449
463
TAPY: number
450
464
451
- // The ratio of the circumference of a circle to its diameter,
452
- // approximately 3.14159
453
- PI: number
465
+ // Math constants
466
+ PI: number // approximately 3.14159 radians (180º)
467
+
468
+ TWO_PI: number // approximately 6.28318 radians (360º)
469
+
470
+ HALF_PI: number // approximately 1.57079 radians (90º)
454
471
</ code > </ pre >
455
472
456
473
< h2 > < a id ="advanced "> Advanced Features</ a > </ h2 >
0 commit comments