Skip to content

Commit 9ec265b

Browse files
committed
update docs
1 parent 0dcfbb6 commit 9ec265b

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed

public/about.html

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,7 @@ <h2><a id="sound">Functions for Sound</a></h2>
499499
<pre><code class="language-typescript">// Plays ZzFX sound effects and returns the played sound array or `false`.
500500
// example: sfx([2,.05,598,.07,0,.19,0,1.32,9.9,-70,0,0,0,0,0,0,.3,.02,0,.04])
501501
// see: https://killedbyapixel.github.io/ZzFX/
502-
// note: if the first argument is omitted, a default sound is played (see DEFAULT_SFX)
503-
// example: sfx() or sfx(null)
502+
// note: if the first argument is omitted, a default "blip" sound is played
504503
sfx(ZzFXparams?: number[], pitchSlide = 0, volumeFactor = 1): number[] | boolean
505504

506505
// Sets the ZzFX global volume factor.
@@ -523,17 +522,6 @@ <h2><a id="math">Functions for Math</a></h2>
523522

524523
<pre><code class="language-typescript">/** General Math */
525524

526-
// Calculates a linear (interpolation) value over `t`.
527-
// example: lerp(0, 50, 0.5) returns 25
528-
// learn more: https://gamedev.net/tutorials/programming/general-and-gameplay-programming/a-brief-introduction-to-lerp-r4954/
529-
lerp(a: number, b: number, t: number): number
530-
531-
// Convert degrees to radians
532-
deg2rad(n: number): number
533-
534-
// Convert radians to degrees
535-
rad2deg(n: number): number
536-
537525
// Returns the rounded value of an number to optional precision.
538526
// example: round(PI) returns 3
539527
// example: round(PI, 3) returns 3.142
@@ -545,6 +533,12 @@ <h2><a id="math">Functions for Math</a></h2>
545533
// example: clamp(-10, 0, 100) return 0
546534
clamp(value: number, min: number, max: number): number
547535

536+
// Convert degrees to radians
537+
deg2rad(n: number): number
538+
539+
// Convert radians to degrees
540+
rad2deg(n: number): number
541+
548542
// Wraps a number between `min` (inclusive) and `max` (exclusive).
549543
// example: wrap(50,0,100) return 50
550544
// example: wrap(125, 0, 100) return 25
@@ -558,10 +552,6 @@ <h2><a id="math">Functions for Math</a></h2>
558552
// example: norm(50, 0, 100) returns 0.5
559553
norm(value, min, max): number
560554

561-
// Interpolate between 2 values using a periodic function (by default is Math.sin).
562-
// example: wave(-100, 100, T)
563-
wave(from: number, to: number, t: number, fn = Math.sin): number
564-
565555
// Returns the sine of a number in radians.
566556
sin(angle: number): number
567557

@@ -585,9 +575,6 @@ <h2><a id="math">Functions for Math</a></h2>
585575
// equal to a given number.
586576
ceil(n: number): number
587577

588-
// Returns the value of a number rounded to the nearest integer.
589-
round(n: number): number
590-
591578
// Rounds down and returns the largest integer less than or
592579
// equal to a given number.
593580
floor(n: number): number
@@ -621,6 +608,17 @@ <h2><a id="math">Functions for Math</a></h2>
621608
// If the number is 0, it will returns 0.
622609
sign(n: number): number
623610

611+
/** Animation Helpers */
612+
613+
// Interpolate between 2 values based on `t` (usually a value between 0 and 1).
614+
// example: lerp(0, 50, 0.5) returns 25
615+
// learn more: https://gamedev.net/tutorials/programming/general-and-gameplay-programming/a-brief-introduction-to-lerp-r4954/
616+
lerp(a: number, b: number, t: number): number
617+
618+
// Interpolate between 2 values using a periodic function (by default is Math.sin).
619+
// example: wave(-100, 100, T)
620+
wave(from: number, to: number, t: number, fn = Math.sin): number
621+
624622
/** Random Number Generator (RNG) */
625623

626624
// Generates a pseudo-random float between min (inclusive)
@@ -640,14 +638,7 @@ <h2><a id="engine-api">Engine API</a></h2>
640638

641639
<p>The following functions are most used internally, but also very useful when creating plugins.</p>
642640

643-
<pre><code class="language-typescript">// gets the canvas
644-
canvas(): HTMLCanvasElement
645-
646-
// Loads a plugin.
647-
// see: https://github.com/litecanvas/game-engine/blob/main/samples/plugin-basics/plugin-basics.js
648-
use(callback): void
649-
650-
// Registers a game event callback and
641+
<pre><code class="language-typescript">// Registers a game event callback and
651642
// returns a function that unregister this callback.
652643
listen(event: string, callback: Function): Function
653644

@@ -664,16 +655,15 @@ <h2><a id="engine-api">Engine API</a></h2>
664655
// Sets the target FPS (frames per second)
665656
framerate(value: number): void
666657

667-
// the following functions are most used by plugins...
668-
669-
// Defines or updates an instance property or method
670-
def(name: string, value: any): void
671-
672658
// Update or reset the palette color
673659
// example: pal(['#000', '#FFF']) is a 1-bit color palette
674660
// example: pal() resets the default color palette
675661
pal(colors: string[]): void
676662

663+
// Loads a plugin.
664+
// see: https://github.com/litecanvas/game-engine/blob/main/samples/plugin-basics/plugin-basics.js
665+
use(callback): void
666+
677667
// pauses the engine loop (update & draw)
678668
pause(): void
679669

@@ -687,19 +677,25 @@ <h2><a id="engine-api">Engine API</a></h2>
687677
// also emits the "quit" event
688678
quit(): void
689679

690-
// use `stat() to get internal informations about an litecanvas' instance
691-
// stat(0) the settings passed to that instance
692-
// stat(1) returns true if the "init" event has already been emitted
693-
// stat(2) the current delta time (dt)
694-
// stat(3) the current canvas element scale (not the context 2D scale)
695-
// stat(4) the attached event callbacks
696-
// stat(5) the current color palette
697-
// stat(6) the default sound used by `sfx()`
698-
// stat(7) the current time scale
699-
// stat(8) the current volume used by ZzFX
700-
// stat(9) the current RNG state
701-
// stat(10) the current font size
702-
// stat(11) the current font family
680+
// gets the canvas
681+
canvas(): HTMLCanvasElement
682+
683+
// Defines or updates an instance property or method
684+
def(name: string, value: any): void
685+
686+
// use `stat(n)` to get internal informations about an litecanvas' instance
687+
// stat(0) => settings passed to that instance
688+
// stat(1) => `true` if the "init" event has already been emitted
689+
// stat(2) => the current delta time (dt)
690+
// stat(3) => the current canvas element scale (not the context 2D scale)
691+
// stat(4) => the attached event callbacks
692+
// stat(5) => the current color palette
693+
// stat(6) => the default sound used by `sfx()`
694+
// stat(7) => the current time scale
695+
// stat(8) => the current volume used by ZzFX
696+
// stat(9) => the current RNG state
697+
// stat(10) => the current font size
698+
// stat(11) => the current font family
703699
// any other values probably will return undefined
704700
stat(n: number): any</code></pre>
705701

@@ -786,16 +782,19 @@ <h3>Public assets</h3>
786782
if (LOADING) return; // wait the asset loader
787783

788784
push()
785+
789786
// These sprites are 16x16 (pretty small),
790787
// so let's zoom in 3x
791788
scale(3)
789+
792790
// draw each sprite
793791
for (let y = 0, index = 0; y < 8; y++) {
794792
for (let x = 0; x < 8; x++, index++) {
795793
// each index is a sprite
796794
image(x * 16, y * 16, sprites[index])
797795
}
798796
}
797+
799798
pop()
800799
}</code></pre>
801800

0 commit comments

Comments
 (0)