littlejsengine 1.6.6 → 1.7.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.
- package/README.md +76 -53
- package/build/littlejs.d.ts +154 -136
- package/build/littlejs.esm.js +461 -305
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +452 -291
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +2317 -2168
- package/examples/breakout/game.js +5 -1
- package/examples/breakout/index.html +5 -5
- package/examples/breakoutTutorial/README.md +6 -6
- package/examples/breakoutTutorial/game.js +3 -0
- package/examples/breakoutTutorial/index.html +3 -3
- package/examples/electron/build.js +105 -0
- package/examples/electron/game.js +4 -2
- package/examples/electron/index.html +13 -2
- package/examples/electron/package.json +5 -3
- package/examples/empty/game.js +3 -1
- package/examples/empty/index.html +1 -1
- package/examples/js13k/build.bat +2 -0
- package/examples/js13k/build.js +110 -0
- package/examples/js13k/game.js +109 -0
- package/examples/js13k/index.html +18 -0
- package/examples/js13k/tiles.png +0 -0
- package/examples/module/game.js +9 -3
- package/examples/module/index.html +2 -2
- package/examples/particles/index.html +7 -13
- package/examples/platformer/game.js +5 -2
- package/examples/platformer/gameEffects.js +12 -12
- package/examples/platformer/gamePlayer.js +2 -2
- package/examples/platformer/index.html +8 -8
- package/examples/puzzle/game.js +5 -3
- package/examples/puzzle/index.html +4 -4
- package/examples/starter/build.bat +2 -78
- package/examples/starter/build.js +109 -0
- package/examples/starter/game.js +4 -1
- package/examples/starter/index.html +15 -18
- package/examples/stress/index.html +5 -7
- package/examples/typescript/build.bat +2 -14
- package/examples/typescript/build.js +31 -0
- package/examples/typescript/game.js +94 -89
- package/examples/typescript/game.ts +9 -3
- package/examples/typescript/index.html +2 -2
- package/package.json +2 -2
- package/src/engine.js +3 -3
- package/src/engineAudio.js +44 -16
- package/src/engineBuild.bat +2 -132
- package/src/engineBuild.js +156 -0
- package/src/engineDebug.js +25 -15
- package/src/engineDraw.js +62 -53
- package/src/engineExport.js +7 -12
- package/src/engineInput.js +27 -35
- package/src/engineObject.js +15 -13
- package/src/engineParticles.js +6 -6
- package/src/engineRelease.js +1 -3
- package/src/engineSettings.js +1 -0
- package/src/engineTileLayer.js +31 -18
- package/src/engineUtilities.js +161 -93
- package/src/engineWebGL.js +63 -27
- package/examples/electron/build.bat +0 -52
package/build/littlejs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module "littlejs.esm" {
|
|
2
2
|
/**
|
|
3
3
|
* LittleJS Module Export
|
|
4
|
-
* - Export engine as a module with
|
|
4
|
+
* - Export engine as a module with functions where necessary
|
|
5
5
|
*/
|
|
6
6
|
/** Set position of camera in world space
|
|
7
7
|
* @param {Vector2} pos
|
|
@@ -146,15 +146,11 @@ declare module "littlejs.esm" {
|
|
|
146
146
|
/** Set to stop medals from being unlockable
|
|
147
147
|
* @param {Boolean} preventUnlock
|
|
148
148
|
* @memberof Settings */
|
|
149
|
-
export function setMedalsPreventUnlock(
|
|
149
|
+
export function setMedalsPreventUnlock(preventUnlock: boolean): void;
|
|
150
150
|
/** Set if watermark with FPS should be shown
|
|
151
151
|
* @param {Boolean} show
|
|
152
152
|
* @memberof Debug */
|
|
153
153
|
export function setShowWatermark(show: boolean): void;
|
|
154
|
-
/** Set if god mode is enabled
|
|
155
|
-
* @param {Boolean} enable
|
|
156
|
-
* @memberof Debug */
|
|
157
|
-
export function setGodMode(enable: boolean): void;
|
|
158
154
|
/** Set key code used to toggle debug mode, Esc by default
|
|
159
155
|
* @param {Number} key
|
|
160
156
|
* @memberof Debug */
|
|
@@ -347,11 +343,6 @@ declare module "littlejs.esm" {
|
|
|
347
343
|
* @default
|
|
348
344
|
* @memberof Debug */
|
|
349
345
|
export let showWatermark: boolean;
|
|
350
|
-
/** True if god mode is enabled, handle this however you want
|
|
351
|
-
* @type {Boolean}
|
|
352
|
-
* @default
|
|
353
|
-
* @memberof Debug */
|
|
354
|
-
export let godMode: boolean;
|
|
355
346
|
/** Asserts if the experssion is false, does not do anything in release builds
|
|
356
347
|
* @param {Boolean} assertion
|
|
357
348
|
* @param {Object} output
|
|
@@ -413,8 +404,9 @@ declare module "littlejs.esm" {
|
|
|
413
404
|
/** Save a canvas to disk
|
|
414
405
|
* @param {HTMLCanvasElement} canvas
|
|
415
406
|
* @param {String} [filename]
|
|
407
|
+
* @param {String} [type='image/png']
|
|
416
408
|
* @memberof Debug */
|
|
417
|
-
export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string): void;
|
|
409
|
+
export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string): void;
|
|
418
410
|
/** A shortcut to get Math.PI
|
|
419
411
|
* @type {Number}
|
|
420
412
|
* @default Math.PI
|
|
@@ -424,69 +416,97 @@ declare module "littlejs.esm" {
|
|
|
424
416
|
* @param {Number} value
|
|
425
417
|
* @return {Number}
|
|
426
418
|
* @memberof Utilities */
|
|
427
|
-
export function abs(
|
|
419
|
+
export function abs(value: number): number;
|
|
428
420
|
/** Returns lowest of two values passed in
|
|
429
421
|
* @param {Number} valueA
|
|
430
422
|
* @param {Number} valueB
|
|
431
423
|
* @return {Number}
|
|
432
424
|
* @memberof Utilities */
|
|
433
|
-
export function min(
|
|
425
|
+
export function min(valueA: number, valueB: number): number;
|
|
434
426
|
/** Returns highest of two values passed in
|
|
435
427
|
* @param {Number} valueA
|
|
436
428
|
* @param {Number} valueB
|
|
437
429
|
* @return {Number}
|
|
438
430
|
* @memberof Utilities */
|
|
439
|
-
export function max(
|
|
431
|
+
export function max(valueA: number, valueB: number): number;
|
|
440
432
|
/** Returns the sign of value passed in (also returns 1 if 0)
|
|
441
433
|
* @param {Number} value
|
|
442
434
|
* @return {Number}
|
|
443
435
|
* @memberof Utilities */
|
|
444
|
-
export function sign(
|
|
436
|
+
export function sign(value: number): number;
|
|
445
437
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
446
438
|
* @param {Number} dividend
|
|
447
439
|
* @param {Number} [divisor=1]
|
|
448
440
|
* @return {Number}
|
|
449
441
|
* @memberof Utilities */
|
|
450
|
-
export function mod(
|
|
442
|
+
export function mod(dividend: number, divisor?: number): number;
|
|
451
443
|
/** Clamps the value beween max and min
|
|
452
444
|
* @param {Number} value
|
|
453
445
|
* @param {Number} [min=0]
|
|
454
446
|
* @param {Number} [max=1]
|
|
455
447
|
* @return {Number}
|
|
456
448
|
* @memberof Utilities */
|
|
457
|
-
export function clamp(
|
|
458
|
-
/** Returns what percentage the value is between
|
|
449
|
+
export function clamp(value: number, min?: number, max?: number): number;
|
|
450
|
+
/** Returns what percentage the value is between valueA and valueB
|
|
459
451
|
* @param {Number} value
|
|
460
|
-
* @param {Number}
|
|
461
|
-
* @param {Number}
|
|
452
|
+
* @param {Number} valueA
|
|
453
|
+
* @param {Number} valueB
|
|
462
454
|
* @return {Number}
|
|
463
455
|
* @memberof Utilities */
|
|
464
|
-
export function percent(
|
|
465
|
-
/**
|
|
456
|
+
export function percent(value: number, valueA: number, valueB: number): number;
|
|
457
|
+
/** Returns signed wrapped distance between the two values passed in
|
|
458
|
+
* @param {Number} valueA
|
|
459
|
+
* @param {Number} valueB
|
|
460
|
+
* @param {Number} [wrapSize=1]
|
|
461
|
+
* @returns {Number}
|
|
462
|
+
* @memberof Utilities */
|
|
463
|
+
export function distanceWrap(valueA: number, valueB: number, wrapSize?: number): number;
|
|
464
|
+
/** Linearly interpolates between values passed in with wrappping
|
|
466
465
|
* @param {Number} percent
|
|
467
|
-
* @param {Number}
|
|
468
|
-
* @param {Number}
|
|
466
|
+
* @param {Number} valueA
|
|
467
|
+
* @param {Number} valueB
|
|
468
|
+
* @param {Number} [wrapSize=1]
|
|
469
|
+
* @returns {Number}
|
|
470
|
+
* @memberof Utilities */
|
|
471
|
+
export function lerpWrap(percent: number, valueA: number, valueB: number, wrapSize?: number): number;
|
|
472
|
+
/** Returns signed wrapped distance between the two angles passed in
|
|
473
|
+
* @param {Number} angleA
|
|
474
|
+
* @param {Number} angleB
|
|
475
|
+
* @returns {Number}
|
|
476
|
+
* @memberof Utilities */
|
|
477
|
+
export function distanceAngle(angleA: number, angleB: number): number;
|
|
478
|
+
/** Linearly interpolates between the angles passed in with wrappping
|
|
479
|
+
* @param {Number} percent
|
|
480
|
+
* @param {Number} angleA
|
|
481
|
+
* @param {Number} angleB
|
|
482
|
+
* @returns {Number}
|
|
483
|
+
* @memberof Utilities */
|
|
484
|
+
export function lerpAngle(percent: number, angleA: number, angleB: number): number;
|
|
485
|
+
/** Linearly interpolates between values passed in using percent
|
|
486
|
+
* @param {Number} percent
|
|
487
|
+
* @param {Number} valueA
|
|
488
|
+
* @param {Number} valueB
|
|
469
489
|
* @return {Number}
|
|
470
490
|
* @memberof Utilities */
|
|
471
|
-
export function lerp(
|
|
491
|
+
export function lerp(percent: number, valueA: number, valueB: number): number;
|
|
472
492
|
/** Applies smoothstep function to the percentage value
|
|
473
|
-
* @param {Number}
|
|
493
|
+
* @param {Number} percent
|
|
474
494
|
* @return {Number}
|
|
475
495
|
* @memberof Utilities */
|
|
476
|
-
export function smoothStep(
|
|
496
|
+
export function smoothStep(percent: number): number;
|
|
477
497
|
/** Returns the nearest power of two not less then the value
|
|
478
498
|
* @param {Number} value
|
|
479
499
|
* @return {Number}
|
|
480
500
|
* @memberof Utilities */
|
|
481
|
-
export function nearestPowerOfTwo(
|
|
501
|
+
export function nearestPowerOfTwo(value: number): number;
|
|
482
502
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
483
503
|
* @param {Vector2} pointA - Center of box A
|
|
484
504
|
* @param {Vector2} sizeA - Size of box A
|
|
485
505
|
* @param {Vector2} pointB - Center of box B
|
|
486
|
-
* @param {Vector2}
|
|
506
|
+
* @param {Vector2} sizeB - Size of box B
|
|
487
507
|
* @return {Boolean} - True if overlapping
|
|
488
508
|
* @memberof Utilities */
|
|
489
|
-
export function isOverlapping(
|
|
509
|
+
export function isOverlapping(pointA: Vector2, sizeA: Vector2, pointB: Vector2, sizeB: Vector2): boolean;
|
|
490
510
|
/** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
|
|
491
511
|
* @param {Number} [frequency=1] - Frequency of the wave in Hz
|
|
492
512
|
* @param {Number} [amplitude=1] - Amplitude (max height) of the wave
|
|
@@ -506,13 +526,13 @@ declare module "littlejs.esm" {
|
|
|
506
526
|
* @param {Number} [valueB=0]
|
|
507
527
|
* @return {Number}
|
|
508
528
|
* @memberof Random */
|
|
509
|
-
export function rand(
|
|
529
|
+
export function rand(valueA?: number, valueB?: number): number;
|
|
510
530
|
/** Returns a floored random value the two values passed in
|
|
511
|
-
* @param {Number}
|
|
531
|
+
* @param {Number} valueA
|
|
512
532
|
* @param {Number} [valueB=0]
|
|
513
533
|
* @return {Number}
|
|
514
534
|
* @memberof Random */
|
|
515
|
-
export function randInt(
|
|
535
|
+
export function randInt(valueA: number, valueB?: number): number;
|
|
516
536
|
/** Randomly returns either -1 or 1
|
|
517
537
|
* @return {Number}
|
|
518
538
|
* @memberof Random */
|
|
@@ -534,22 +554,37 @@ declare module "littlejs.esm" {
|
|
|
534
554
|
* @param {Boolean} [linear]
|
|
535
555
|
* @return {Color}
|
|
536
556
|
* @memberof Random */
|
|
537
|
-
export function randColor(
|
|
538
|
-
/**
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
557
|
+
export function randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
558
|
+
/**
|
|
559
|
+
* Seeded random number generator
|
|
560
|
+
* - Can be used to create a deterministic random number sequence
|
|
561
|
+
* @example
|
|
562
|
+
* let r = new RandomGenerator(123); // random number generator with seed 123
|
|
563
|
+
* let a = r.rand(); // random value between 0 and 1
|
|
564
|
+
* let b = r.randInt(10); // random integer between 0 and 9
|
|
565
|
+
* r.seed = 123; // reset the seed
|
|
566
|
+
* let c = r.rand(); // the same value as a
|
|
567
|
+
*/
|
|
568
|
+
export class RandomGenerator {
|
|
569
|
+
/** Create a random number generator with the seed passed in
|
|
570
|
+
* @param {Number} seed - Starting seed */
|
|
571
|
+
constructor(seed: number);
|
|
572
|
+
/** @property {Number} - random seed */
|
|
573
|
+
seed: number;
|
|
574
|
+
/** Returns a seeded random value between the two values passed in
|
|
575
|
+
* @param {Number} [valueA=1]
|
|
576
|
+
* @param {Number} [valueB=0]
|
|
577
|
+
* @return {Number} */
|
|
578
|
+
float(valueA?: number, valueB?: number): number;
|
|
579
|
+
/** Returns a floored seeded random value the two values passed in
|
|
580
|
+
* @param {Number} valueA
|
|
581
|
+
* @param {Number} [valueB=0]
|
|
582
|
+
* @return {Number} */
|
|
583
|
+
int(valueA: number, valueB?: number): number;
|
|
584
|
+
/** Randomly returns either -1 or 1 deterministically
|
|
585
|
+
* @return {Number} */
|
|
586
|
+
sign(): number;
|
|
587
|
+
}
|
|
553
588
|
/**
|
|
554
589
|
* 2D Vector object with vector math library
|
|
555
590
|
* - Functions do not change this so they can be chained together
|
|
@@ -572,25 +607,25 @@ declare module "littlejs.esm" {
|
|
|
572
607
|
* @return {Vector2} */
|
|
573
608
|
copy(): Vector2;
|
|
574
609
|
/** Returns a copy of this vector plus the vector passed in
|
|
575
|
-
* @param {Vector2} vector
|
|
610
|
+
* @param {Vector2} v - other vector
|
|
576
611
|
* @return {Vector2} */
|
|
577
|
-
add(v:
|
|
612
|
+
add(v: Vector2): Vector2;
|
|
578
613
|
/** Returns a copy of this vector minus the vector passed in
|
|
579
|
-
* @param {Vector2} vector
|
|
614
|
+
* @param {Vector2} v - other vector
|
|
580
615
|
* @return {Vector2} */
|
|
581
|
-
subtract(v:
|
|
616
|
+
subtract(v: Vector2): Vector2;
|
|
582
617
|
/** Returns a copy of this vector times the vector passed in
|
|
583
|
-
* @param {Vector2} vector
|
|
618
|
+
* @param {Vector2} v - other vector
|
|
584
619
|
* @return {Vector2} */
|
|
585
|
-
multiply(v:
|
|
620
|
+
multiply(v: Vector2): Vector2;
|
|
586
621
|
/** Returns a copy of this vector divided by the vector passed in
|
|
587
|
-
* @param {Vector2} vector
|
|
622
|
+
* @param {Vector2} v - other vector
|
|
588
623
|
* @return {Vector2} */
|
|
589
|
-
divide(v:
|
|
624
|
+
divide(v: Vector2): Vector2;
|
|
590
625
|
/** Returns a copy of this vector scaled by the vector passed in
|
|
591
|
-
* @param {Number} scale
|
|
626
|
+
* @param {Number} s - scale
|
|
592
627
|
* @return {Vector2} */
|
|
593
|
-
scale(s:
|
|
628
|
+
scale(s: number): Vector2;
|
|
594
629
|
/** Returns the length of this vector
|
|
595
630
|
* @return {Number} */
|
|
596
631
|
length(): number;
|
|
@@ -598,13 +633,13 @@ declare module "littlejs.esm" {
|
|
|
598
633
|
* @return {Number} */
|
|
599
634
|
lengthSquared(): number;
|
|
600
635
|
/** Returns the distance from this vector to vector passed in
|
|
601
|
-
* @param {Vector2} vector
|
|
636
|
+
* @param {Vector2} v - other vector
|
|
602
637
|
* @return {Number} */
|
|
603
|
-
distance(v:
|
|
638
|
+
distance(v: Vector2): number;
|
|
604
639
|
/** Returns the distance squared from this vector to vector passed in
|
|
605
|
-
* @param {Vector2} vector
|
|
640
|
+
* @param {Vector2} v - other vector
|
|
606
641
|
* @return {Number} */
|
|
607
|
-
distanceSquared(v:
|
|
642
|
+
distanceSquared(v: Vector2): number;
|
|
608
643
|
/** Returns a new vector in same direction as this one with the length passed in
|
|
609
644
|
* @param {Number} [length=1]
|
|
610
645
|
* @return {Vector2} */
|
|
@@ -614,13 +649,13 @@ declare module "littlejs.esm" {
|
|
|
614
649
|
* @return {Vector2} */
|
|
615
650
|
clampLength(length?: number): Vector2;
|
|
616
651
|
/** Returns the dot product of this and the vector passed in
|
|
617
|
-
* @param {Vector2} vector
|
|
652
|
+
* @param {Vector2} v - other vector
|
|
618
653
|
* @return {Number} */
|
|
619
|
-
dot(v:
|
|
654
|
+
dot(v: Vector2): number;
|
|
620
655
|
/** Returns the cross product of this and the vector passed in
|
|
621
|
-
* @param {Vector2} vector
|
|
656
|
+
* @param {Vector2} v - other vector
|
|
622
657
|
* @return {Number} */
|
|
623
|
-
cross(v:
|
|
658
|
+
cross(v: Vector2): number;
|
|
624
659
|
/** Returns the angle of this vector, up is angle 0
|
|
625
660
|
* @return {Number} */
|
|
626
661
|
angle(): number;
|
|
@@ -628,11 +663,11 @@ declare module "littlejs.esm" {
|
|
|
628
663
|
* @param {Number} [angle=0]
|
|
629
664
|
* @param {Number} [length=1]
|
|
630
665
|
* @return {Vector2} */
|
|
631
|
-
setAngle(
|
|
666
|
+
setAngle(angle?: number, length?: number): Vector2;
|
|
632
667
|
/** Returns copy of this vector rotated by the angle passed in
|
|
633
668
|
* @param {Number} angle
|
|
634
669
|
* @return {Vector2} */
|
|
635
|
-
rotate(
|
|
670
|
+
rotate(angle: number): Vector2;
|
|
636
671
|
/** Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
|
|
637
672
|
* @return {Number} */
|
|
638
673
|
direction(): number;
|
|
@@ -646,10 +681,10 @@ declare module "littlejs.esm" {
|
|
|
646
681
|
* @return {Number} */
|
|
647
682
|
area(): number;
|
|
648
683
|
/** Returns a new vector that is p percent between this and the vector passed in
|
|
649
|
-
* @param {Vector2} vector
|
|
684
|
+
* @param {Vector2} v - other vector
|
|
650
685
|
* @param {Number} percent
|
|
651
686
|
* @return {Vector2} */
|
|
652
|
-
lerp(v:
|
|
687
|
+
lerp(v: Vector2, percent: number): Vector2;
|
|
653
688
|
/** Returns true if this vector is within the bounds of an array size passed in
|
|
654
689
|
* @param {Vector2} arraySize
|
|
655
690
|
* @return {Boolean} */
|
|
@@ -669,11 +704,11 @@ declare module "littlejs.esm" {
|
|
|
669
704
|
* let e = HSL(.3, 1, .5); // green using hsl color
|
|
670
705
|
*/
|
|
671
706
|
export class Color {
|
|
672
|
-
/** Create a color with the components passed in, white by default
|
|
673
|
-
* @param {Number} [
|
|
674
|
-
* @param {Number} [
|
|
675
|
-
* @param {Number} [
|
|
676
|
-
* @param {Number} [
|
|
707
|
+
/** Create a color with the rgba components passed in, white by default
|
|
708
|
+
* @param {Number} [r=1] - red
|
|
709
|
+
* @param {Number} [g=1] - green
|
|
710
|
+
* @param {Number} [b=1] - blue
|
|
711
|
+
* @param {Number} [a=1] - alpha*/
|
|
677
712
|
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
678
713
|
/** @property {Number} - Red */
|
|
679
714
|
r: number;
|
|
@@ -687,39 +722,39 @@ declare module "littlejs.esm" {
|
|
|
687
722
|
* @return {Color} */
|
|
688
723
|
copy(): Color;
|
|
689
724
|
/** Returns a copy of this color plus the color passed in
|
|
690
|
-
* @param {Color} color
|
|
725
|
+
* @param {Color} c - other color
|
|
691
726
|
* @return {Color} */
|
|
692
|
-
add(c:
|
|
727
|
+
add(c: Color): Color;
|
|
693
728
|
/** Returns a copy of this color minus the color passed in
|
|
694
|
-
* @param {Color} color
|
|
729
|
+
* @param {Color} c - other color
|
|
695
730
|
* @return {Color} */
|
|
696
|
-
subtract(c:
|
|
731
|
+
subtract(c: Color): Color;
|
|
697
732
|
/** Returns a copy of this color times the color passed in
|
|
698
|
-
* @param {Color} color
|
|
733
|
+
* @param {Color} c - other color
|
|
699
734
|
* @return {Color} */
|
|
700
|
-
multiply(c:
|
|
735
|
+
multiply(c: Color): Color;
|
|
701
736
|
/** Returns a copy of this color divided by the color passed in
|
|
702
|
-
* @param {Color} color
|
|
737
|
+
* @param {Color} c - other color
|
|
703
738
|
* @return {Color} */
|
|
704
|
-
divide(c:
|
|
739
|
+
divide(c: Color): Color;
|
|
705
740
|
/** Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
|
|
706
741
|
* @param {Number} scale
|
|
707
742
|
* @param {Number} [alphaScale=scale]
|
|
708
743
|
* @return {Color} */
|
|
709
|
-
scale(
|
|
744
|
+
scale(scale: number, alphaScale?: number): Color;
|
|
710
745
|
/** Returns a copy of this color clamped to the valid range between 0 and 1
|
|
711
746
|
* @return {Color} */
|
|
712
747
|
clamp(): Color;
|
|
713
748
|
/** Returns a new color that is p percent between this and the color passed in
|
|
714
|
-
* @param {Color} color
|
|
749
|
+
* @param {Color} c - other color
|
|
715
750
|
* @param {Number} percent
|
|
716
751
|
* @return {Color} */
|
|
717
|
-
lerp(c:
|
|
752
|
+
lerp(c: Color, percent: number): Color;
|
|
718
753
|
/** Sets this color given a hue, saturation, lightness, and alpha
|
|
719
|
-
* @param {Number} [
|
|
720
|
-
* @param {Number} [
|
|
721
|
-
* @param {Number} [
|
|
722
|
-
* @param {Number} [
|
|
754
|
+
* @param {Number} [h=0] - hue
|
|
755
|
+
* @param {Number} [s=0] - saturation
|
|
756
|
+
* @param {Number} [l=1] - lightness
|
|
757
|
+
* @param {Number} [a=1] - alpha
|
|
723
758
|
* @return {Color} */
|
|
724
759
|
setHSLA(h?: number, s?: number, l?: number, a?: number): Color;
|
|
725
760
|
/** Returns this color expressed in hsla format
|
|
@@ -799,32 +834,32 @@ declare module "littlejs.esm" {
|
|
|
799
834
|
export function vec2(x?: number, y?: number): Vector2;
|
|
800
835
|
/**
|
|
801
836
|
* Create a color object with RGBA values
|
|
802
|
-
* @param {Number} [r=1]
|
|
803
|
-
* @param {Number} [g=1]
|
|
804
|
-
* @param {Number} [b=1]
|
|
805
|
-
* @param {Number} [a=1]
|
|
837
|
+
* @param {Number} [r=1] - red
|
|
838
|
+
* @param {Number} [g=1] - green
|
|
839
|
+
* @param {Number} [b=1] - blue
|
|
840
|
+
* @param {Number} [a=1] - alpha
|
|
806
841
|
* @return {Color}
|
|
807
842
|
* @memberof Utilities
|
|
808
843
|
*/
|
|
809
844
|
export function rgb(r?: number, g?: number, b?: number, a?: number): Color;
|
|
810
845
|
/**
|
|
811
846
|
* Create a color object with HSLA values
|
|
812
|
-
* @param {Number} [h=0]
|
|
813
|
-
* @param {Number} [s=0]
|
|
814
|
-
* @param {Number} [l=1]
|
|
815
|
-
* @param {Number} [a=1]
|
|
847
|
+
* @param {Number} [h=0] - hue
|
|
848
|
+
* @param {Number} [s=0] - saturation
|
|
849
|
+
* @param {Number} [l=1] - lightness
|
|
850
|
+
* @param {Number} [a=1] - alpha
|
|
816
851
|
* @return {Color}
|
|
817
852
|
* @memberof Utilities
|
|
818
853
|
*/
|
|
819
854
|
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
820
855
|
/**
|
|
821
856
|
* LittleJS Object Base Object Class
|
|
822
|
-
* -
|
|
857
|
+
* - Top level object class used by the engine
|
|
823
858
|
* - Automatically adds self to object list
|
|
824
859
|
* - Will be updated and rendered each frame
|
|
825
860
|
* - Renders as a sprite from a tilesheet by default
|
|
826
861
|
* - Can have color and addtive color applied
|
|
827
|
-
* -
|
|
862
|
+
* - 2D Physics and collision system
|
|
828
863
|
* - Sorted by renderOrder
|
|
829
864
|
* - Objects can have children attached
|
|
830
865
|
* - Parents are updated before children, and set child transform
|
|
@@ -908,13 +943,13 @@ declare module "littlejs.esm" {
|
|
|
908
943
|
* @param {EngineObject} object - the object to test against
|
|
909
944
|
* @return {Boolean} - true if the collision should be resolved
|
|
910
945
|
*/
|
|
911
|
-
collideWithObject(
|
|
946
|
+
collideWithObject(object: EngineObject): boolean;
|
|
912
947
|
/** How long since the object was created
|
|
913
948
|
* @return {Number} */
|
|
914
949
|
getAliveTime(): number;
|
|
915
950
|
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
916
951
|
* @param {Vector2} acceleration */
|
|
917
|
-
applyAcceleration(
|
|
952
|
+
applyAcceleration(acceleration: Vector2): void;
|
|
918
953
|
/** Apply force to this object (adjust velocity, affected by mass)
|
|
919
954
|
* @param {Vector2} force */
|
|
920
955
|
applyForce(force: Vector2): void;
|
|
@@ -965,13 +1000,11 @@ declare module "littlejs.esm" {
|
|
|
965
1000
|
* @memberof Draw */
|
|
966
1001
|
export let mainCanvasSize: Vector2;
|
|
967
1002
|
/** Convert from screen to world space coordinates
|
|
968
|
-
* - if calling outside of render, you may need to manually set mainCanvasSize
|
|
969
1003
|
* @param {Vector2} screenPos
|
|
970
1004
|
* @return {Vector2}
|
|
971
1005
|
* @memberof Draw */
|
|
972
1006
|
export function screenToWorld(screenPos: Vector2): Vector2;
|
|
973
1007
|
/** Convert from world to screen space coordinates
|
|
974
|
-
* - if calling outside of render, you may need to manually set mainCanvasSize
|
|
975
1008
|
* @param {Vector2} worldPos
|
|
976
1009
|
* @return {Vector2}
|
|
977
1010
|
* @memberof Draw */
|
|
@@ -986,42 +1019,25 @@ declare module "littlejs.esm" {
|
|
|
986
1019
|
* @param {Boolean} [mirror=0] - If true image is flipped along the Y axis
|
|
987
1020
|
* @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
|
|
988
1021
|
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1022
|
+
* @param {Boolean} [screenSpace=0] - If true the pos and size are in screen space
|
|
989
1023
|
* @memberof Draw */
|
|
990
|
-
export function drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean): void;
|
|
1024
|
+
export function drawTile(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean): void;
|
|
991
1025
|
/** Draw colored rect centered on pos
|
|
992
1026
|
* @param {Vector2} pos
|
|
993
1027
|
* @param {Vector2} [size=Vector2(1,1)]
|
|
994
1028
|
* @param {Color} [color=Color()]
|
|
995
1029
|
* @param {Number} [angle=0]
|
|
996
1030
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1031
|
+
* @param {Boolean} [screenSpace=0]
|
|
997
1032
|
* @memberof Draw */
|
|
998
|
-
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean): void;
|
|
999
|
-
/** Draw textured tile centered on pos in screen space
|
|
1000
|
-
* @param {Vector2} pos - Center of the tile
|
|
1001
|
-
* @param {Vector2} [size=Vector2(1,1)] - Size of the tile
|
|
1002
|
-
* @param {Number} [tileIndex=-1] - Tile index to use, negative is untextured
|
|
1003
|
-
* @param {Vector2} [tileSize=tileSizeDefault] - Tile size in source pixels
|
|
1004
|
-
* @param {Color} [color=Color()]
|
|
1005
|
-
* @param {Number} [angle=0]
|
|
1006
|
-
* @param {Boolean} [mirror=0]
|
|
1007
|
-
* @param {Color} [additiveColor=Color(0,0,0,0)]
|
|
1008
|
-
* @param {Boolean} [useWebGL=glEnable]
|
|
1009
|
-
* @memberof Draw */
|
|
1010
|
-
export function drawTileScreenSpace(pos: Vector2, size?: Vector2, tileIndex?: number, tileSize?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean): void;
|
|
1011
|
-
/** Draw colored rectangle in screen space
|
|
1012
|
-
* @param {Vector2} pos
|
|
1013
|
-
* @param {Vector2} [size=Vector2(1,1)]
|
|
1014
|
-
* @param {Color} [color=Color()]
|
|
1015
|
-
* @param {Number} [angle=0]
|
|
1016
|
-
* @param {Boolean} [useWebGL=glEnable]
|
|
1017
|
-
* @memberof Draw */
|
|
1018
|
-
export function drawRectScreenSpace(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean): void;
|
|
1033
|
+
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean): void;
|
|
1019
1034
|
/** Draw colored line between two points
|
|
1020
1035
|
* @param {Vector2} posA
|
|
1021
1036
|
* @param {Vector2} posB
|
|
1022
1037
|
* @param {Number} [thickness=.1]
|
|
1023
1038
|
* @param {Color} [color=Color()]
|
|
1024
1039
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1040
|
+
* @param {Boolean} [screenSpace=0]
|
|
1025
1041
|
* @memberof Draw */
|
|
1026
1042
|
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean): void;
|
|
1027
1043
|
/** Draw directly to a 2d canvas context in world space
|
|
@@ -1031,8 +1047,9 @@ declare module "littlejs.esm" {
|
|
|
1031
1047
|
* @param {Boolean} mirror
|
|
1032
1048
|
* @param {Function} drawFunction
|
|
1033
1049
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1050
|
+
* @param {Boolean} [screenSpace=0]
|
|
1034
1051
|
* @memberof Draw */
|
|
1035
|
-
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, context?: CanvasRenderingContext2D): void;
|
|
1052
|
+
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, context?: CanvasRenderingContext2D, screenSpace?: boolean): void;
|
|
1036
1053
|
/** Enable normal or additive blend mode
|
|
1037
1054
|
* @param {Boolean} [additive=0]
|
|
1038
1055
|
* @param {Boolean} [useWebGL=glEnable]
|
|
@@ -1091,20 +1108,20 @@ declare module "littlejs.esm" {
|
|
|
1091
1108
|
paddingSize: Vector2;
|
|
1092
1109
|
startTileIndex: number;
|
|
1093
1110
|
context: CanvasRenderingContext2D;
|
|
1094
|
-
/** Draw text in
|
|
1111
|
+
/** Draw text in world space using the image font
|
|
1095
1112
|
* @param {String} text
|
|
1096
1113
|
* @param {Vector2} pos
|
|
1097
|
-
* @param {Number} [scale
|
|
1114
|
+
* @param {Number} [scale=.25]
|
|
1098
1115
|
* @param {Boolean} [center]
|
|
1099
1116
|
*/
|
|
1100
|
-
|
|
1101
|
-
/** Draw text in
|
|
1117
|
+
drawText(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
1118
|
+
/** Draw text in screen space using the image font
|
|
1102
1119
|
* @param {String} text
|
|
1103
1120
|
* @param {Vector2} pos
|
|
1104
|
-
* @param {Number} [scale
|
|
1121
|
+
* @param {Number} [scale=4]
|
|
1105
1122
|
* @param {Boolean} [center]
|
|
1106
1123
|
*/
|
|
1107
|
-
|
|
1124
|
+
drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
1108
1125
|
}
|
|
1109
1126
|
/** Returns true if fullscreen mode is active
|
|
1110
1127
|
* @return {Boolean}
|
|
@@ -1230,6 +1247,7 @@ declare module "littlejs.esm" {
|
|
|
1230
1247
|
range: number;
|
|
1231
1248
|
/** @property {Number} - At what percentage of range should it start tapering off */
|
|
1232
1249
|
taper: number;
|
|
1250
|
+
/** @property {Number} - How much to randomize frequency each time sound plays */
|
|
1233
1251
|
randomness: any;
|
|
1234
1252
|
cachedSamples: any[];
|
|
1235
1253
|
/** Play the sound
|
|
@@ -1371,7 +1389,7 @@ declare module "littlejs.esm" {
|
|
|
1371
1389
|
* @return {Boolean}
|
|
1372
1390
|
* @memberof TileCollision */
|
|
1373
1391
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
1374
|
-
/** Return the center of tile if any that is hit (
|
|
1392
|
+
/** Return the center of tile if any that is hit (does not return the exact intersection)
|
|
1375
1393
|
* @param {Vector2} posStart
|
|
1376
1394
|
* @param {Vector2} posEnd
|
|
1377
1395
|
* @param {EngineObject} [object]
|