@@ -370,34 +370,28 @@ <h2><a id="globals">Global Variables</a></h2>
370
370
< pre > < code class ="language-typescript "> // the game canvas
371
371
CANVAS: HTMLCanvasElement
372
372
373
+ // the amount of time since the game started
374
+ T: number
375
+
373
376
// the game screen width
374
- WIDTH : number
377
+ W : number
375
378
376
379
// the game screen height
377
- HEIGHT : number
380
+ H : number
378
381
379
382
// the center X of game screen
380
- CENTERX : number
383
+ CX : number
381
384
382
385
// 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
387
387
388
388
// the current mouse's X-position
389
389
// or -1 (if the mouse was not used or detected)
390
- MOUSEX : number
390
+ MX : number
391
391
392
392
// the current mouse's Y-position
393
393
// 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
401
395
402
396
// Math constants
403
397
PI: number // approximately 3.14 radians (180°)
@@ -585,6 +579,10 @@ <h2><a id="math">Functions for Math</a></h2>
585
579
// example: norm(50, 0, 100) returns 0.5
586
580
norm(value, min, max): number
587
581
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
+
588
586
// Returns the sine of a number in radians.
589
587
sin(angle: number): number
590
588
@@ -654,10 +652,10 @@ <h2><a id="math">Functions for Math</a></h2>
654
652
// and max (inclusive)
655
653
randi(min = 0, max = 1): number
656
654
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
659
656
// 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 >
661
659
662
660
< h2 > < a id ="engine-api "> Engine API</ a > </ h2 >
663
661
@@ -681,26 +679,38 @@ <h2><a id="engine-api">Engine API</a></h2>
681
679
// A value of 0 freezes time (equivalent to pausing).
682
680
timescale(value: number): void
683
681
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
686
684
687
685
// the following functions are most used by plugins...
688
686
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
691
689
692
690
// Update or reset the palette color
693
691
// example: pal(['#000', '#FFF']) is a 1-bit color palette
694
692
// example: pal() resets the default color palette
695
693
pal(index: string[]): void
696
694
697
- // Gets the color value given its index.
698
- // example: getcolor(0) returns "#111"
699
- getcolor(index: number): string
700
-
701
695
// shutdown the engine
702
696
// 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 >
704
714
705
715
< h2 > < a id ="advanced "> Playground Features</ a > </ h2 >
706
716
0 commit comments