@@ -370,34 +370,28 @@ <h2><a id="globals">Global Variables</a></h2>
370370 < pre > < code class ="language-typescript "> // the game canvas
371371CANVAS: HTMLCanvasElement
372372
373+ // the amount of time since the game started
374+ T: number
375+
373376// the game screen width
374- WIDTH : number
377+ W : number
375378
376379// the game screen height
377- HEIGHT : number
380+ H : number
378381
379382// the center X of game screen
380- CENTERX : number
383+ CX : number
381384
382385// the center Y of game screen
383- CENTERY: number
384-
385- // the amount of time since the game started
386- ELAPSED: number
386+ CY: number
387387
388388// the current mouse's X-position
389389// or -1 (if the mouse was not used or detected)
390- MOUSEX : number
390+ MX : number
391391
392392// the current mouse's Y-position
393393// or -1 (if the mouse was not used or detected)
394- MOUSEY: number
395-
396- // the default sound played in `sfx()`
397- DEFAULT_SFX: number[]
398-
399- // the list of colors in the current palette
400- COLORS: string[]
394+ MY: number
401395
402396// Math constants
403397PI: number // approximately 3.14 radians (180°)
@@ -585,6 +579,10 @@ <h2><a id="math">Functions for Math</a></h2>
585579// example: norm(50, 0, 100) returns 0.5
586580norm(value, min, max): number
587581
582+ // Interpolate between 2 values using a periodic function (by default is Math.sin).
583+ // example: wave(-100, 100, T)
584+ wave(from: number, to: number, t: number, fn = Math.sin): number
585+
588586// Returns the sine of a number in radians.
589587sin(angle: number): number
590588
@@ -654,10 +652,10 @@ <h2><a id="math">Functions for Math</a></h2>
654652// and max (inclusive)
655653randi(min = 0, max = 1): number
656654
657- // If a value is passed, initializes the random number generator (RNG)
658- // with an explicit seed value (a number > = 0). Otherwise, returns the current seed state.
655+ // initializes the random number generator (RNG) with an explicit seed value
659656// By default, the initial seed is the current timestamp (from `Date.now()`).
660- seed(value: number | null): number</ code > </ pre >
657+ // Note: The value should be a integer number greater than or equal to zero.
658+ rseed(value: number): void</ code > </ pre >
661659
662660 < h2 > < a id ="engine-api "> Engine API</ a > </ h2 >
663661
@@ -681,26 +679,38 @@ <h2><a id="engine-api">Engine API</a></h2>
681679// A value of 0 freezes time (equivalent to pausing).
682680timescale(value: number): void
683681
684- // Sets the target FPS (frames per second or frame rate )
685- setfps (value: number): void
682+ // Sets the target FPS (frames per second)
683+ framerate (value: number): void
686684
687685// the following functions are most used by plugins...
688686
689- // Create or update an global variables (and instance properties)
690- setvar (name: string, value: any): void
687+ // Defines or updates an instance property or method
688+ def (name: string, value: any): void
691689
692690// Update or reset the palette color
693691// example: pal(['#000', '#FFF']) is a 1-bit color palette
694692// example: pal() resets the default color palette
695693pal(index: string[]): void
696694
697- // Gets the color value given its index.
698- // example: getcolor(0) returns "#111"
699- getcolor(index: number): string
700-
701695// shutdown the engine
702696// also emits the "quit" event
703- quit(): void</ code > </ pre >
697+ quit(): void
698+
699+ // use `stat() to get internal informations about an litecanvas' instance
700+ // stat(0) the settings passed to that instance
701+ // stat(1) returns true if the "init" event has already been emitted
702+ // stat(2) the current ID returned by last requestAnimationFrame
703+ // stat(3) the current canvas element scale (not the context 2D scale)
704+ // stat(4) the attached event callbacks
705+ // stat(5) the current color palette
706+ // stat(6) the default sound used by `sfx()`
707+ // stat(7) the current time scale
708+ // stat(8) the current volume used by ZzFX
709+ // stat(9) the current RNG state
710+ // stat(10) the current font size
711+ // stat(11) the current font family
712+ // any other value returns undefined
713+ stat(n: number): any</ code > </ pre >
704714
705715 < h2 > < a id ="advanced "> Playground Features</ a > </ h2 >
706716
0 commit comments