littlejsengine 1.11.8 → 1.11.9
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/dist/littlejs.d.ts +14 -14
- package/dist/littlejs.esm.js +22 -22
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +22 -22
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +22 -22
- package/examples/index.html +8 -2
- package/package.json +1 -1
- package/reference.md +3 -3
- package/src/engine.js +1 -1
- package/src/engineObject.js +3 -3
- package/src/engineUtilities.js +18 -18
package/src/engineObject.js
CHANGED
|
@@ -118,7 +118,7 @@ class EngineObject
|
|
|
118
118
|
{
|
|
119
119
|
// copy parent pos/angle
|
|
120
120
|
const mirror = parent.getMirrorSign();
|
|
121
|
-
this.pos = this.localPos.multiply(vec2(mirror,1)).rotate(
|
|
121
|
+
this.pos = this.localPos.multiply(vec2(mirror,1)).rotate(parent.angle).add(parent.pos);
|
|
122
122
|
this.angle = mirror*this.localAngle + parent.angle;
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -346,11 +346,11 @@ class EngineObject
|
|
|
346
346
|
|
|
347
347
|
/** Convert from local space to world space for a vector (rotation only)
|
|
348
348
|
* @param {Vector2} vec - local space vector */
|
|
349
|
-
localToWorldVector(vec) { return vec.rotate(
|
|
349
|
+
localToWorldVector(vec) { return vec.rotate(this.angle); }
|
|
350
350
|
|
|
351
351
|
/** Convert from world space to local space for a vector (rotation only)
|
|
352
352
|
* @param {Vector2} vec - world space vector */
|
|
353
|
-
worldToLocalVector(vec) { return vec.rotate(this.angle); }
|
|
353
|
+
worldToLocalVector(vec) { return vec.rotate(-this.angle); }
|
|
354
354
|
|
|
355
355
|
/** Called to check if a tile collision should be resolved
|
|
356
356
|
* @param {Number} tileData - the value of the tile at the position
|
package/src/engineUtilities.js
CHANGED
|
@@ -272,7 +272,7 @@ class RandomGenerator
|
|
|
272
272
|
this.seed ^= this.seed << 13;
|
|
273
273
|
this.seed ^= this.seed >>> 17;
|
|
274
274
|
this.seed ^= this.seed << 5;
|
|
275
|
-
return valueB + (valueA - valueB) *
|
|
275
|
+
return valueB + (valueA - valueB) * ((this.seed >>> 0) / 2**32);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
/** Returns a floored seeded random value the two values passed in
|
|
@@ -461,11 +461,11 @@ class Vector2
|
|
|
461
461
|
return this.x*v.y - this.y*v.x;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
-
/** Returns the angle of this vector, up is angle 0
|
|
464
|
+
/** Returns the clockwise angle of this vector, up is angle 0
|
|
465
465
|
* @return {Number} */
|
|
466
466
|
angle() { return Math.atan2(this.x, this.y); }
|
|
467
467
|
|
|
468
|
-
/** Sets this vector with angle and length passed in
|
|
468
|
+
/** Sets this vector with clockwise angle and length passed in
|
|
469
469
|
* @param {Number} [angle]
|
|
470
470
|
* @param {Number} [length]
|
|
471
471
|
* @return {Vector2} */
|
|
@@ -476,13 +476,13 @@ class Vector2
|
|
|
476
476
|
return this;
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
-
/** Returns copy of this vector rotated by the angle passed in
|
|
479
|
+
/** Returns copy of this vector rotated by the clockwise angle passed in
|
|
480
480
|
* @param {Number} angle
|
|
481
481
|
* @return {Vector2} */
|
|
482
482
|
rotate(angle)
|
|
483
483
|
{
|
|
484
|
-
const c = Math.cos(angle), s = Math.sin(angle);
|
|
485
|
-
return new Vector2(this.x*c
|
|
484
|
+
const c = Math.cos(-angle), s = Math.sin(-angle);
|
|
485
|
+
return new Vector2(this.x*c - this.y*s, this.x*s + this.y*c);
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
/** Set the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)
|
|
@@ -817,57 +817,57 @@ class Color
|
|
|
817
817
|
///////////////////////////////////////////////////////////////////////////////
|
|
818
818
|
// default colors
|
|
819
819
|
|
|
820
|
-
/** Color - White
|
|
820
|
+
/** Color - White #ffffff
|
|
821
821
|
* @type {Color}
|
|
822
822
|
* @memberof Utilities */
|
|
823
|
-
const WHITE = rgb();
|
|
823
|
+
const WHITE = rgb();
|
|
824
824
|
|
|
825
|
-
/** Color - Black
|
|
825
|
+
/** Color - Black #000000
|
|
826
826
|
* @type {Color}
|
|
827
827
|
* @memberof Utilities */
|
|
828
828
|
const BLACK = rgb(0,0,0);
|
|
829
829
|
|
|
830
|
-
/** Color - Gray
|
|
830
|
+
/** Color - Gray #808080
|
|
831
831
|
* @type {Color}
|
|
832
832
|
* @memberof Utilities */
|
|
833
833
|
const GRAY = rgb(.5,.5,.5);
|
|
834
834
|
|
|
835
|
-
/** Color - Red
|
|
835
|
+
/** Color - Red #ff0000
|
|
836
836
|
* @type {Color}
|
|
837
837
|
* @memberof Utilities */
|
|
838
838
|
const RED = rgb(1,0,0);
|
|
839
839
|
|
|
840
|
-
/** Color - Orange
|
|
840
|
+
/** Color - Orange #ff8000
|
|
841
841
|
* @type {Color}
|
|
842
842
|
* @memberof Utilities */
|
|
843
843
|
const ORANGE = rgb(1,.5,0);
|
|
844
844
|
|
|
845
|
-
/** Color - Yellow
|
|
845
|
+
/** Color - Yellow #ffff00
|
|
846
846
|
* @type {Color}
|
|
847
847
|
* @memberof Utilities */
|
|
848
848
|
const YELLOW = rgb(1,1,0);
|
|
849
849
|
|
|
850
|
-
/** Color - Green
|
|
850
|
+
/** Color - Green #00ff00
|
|
851
851
|
* @type {Color}
|
|
852
852
|
* @memberof Utilities */
|
|
853
853
|
const GREEN = rgb(0,1,0);
|
|
854
854
|
|
|
855
|
-
/** Color - Cyan
|
|
855
|
+
/** Color - Cyan #00ffff
|
|
856
856
|
* @type {Color}
|
|
857
857
|
* @memberof Utilities */
|
|
858
858
|
const CYAN = rgb(0,1,1);
|
|
859
859
|
|
|
860
|
-
/** Color - Blue
|
|
860
|
+
/** Color - Blue #0000ff
|
|
861
861
|
* @type {Color}
|
|
862
862
|
* @memberof Utilities */
|
|
863
863
|
const BLUE = rgb(0,0,1);
|
|
864
864
|
|
|
865
|
-
/** Color - Purple
|
|
865
|
+
/** Color - Purple #8000ff
|
|
866
866
|
* @type {Color}
|
|
867
867
|
* @memberof Utilities */
|
|
868
868
|
const PURPLE = rgb(.5,0,1);
|
|
869
869
|
|
|
870
|
-
/** Color - Magenta
|
|
870
|
+
/** Color - Magenta #ff00ff
|
|
871
871
|
* @type {Color}
|
|
872
872
|
* @memberof Utilities */
|
|
873
873
|
const MAGENTA = rgb(1,0,1);
|