littlejsengine 1.14.9 → 1.14.11
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 +12 -11
- package/dist/littlejs.esm.js +121 -73
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +120 -73
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +102 -56
- package/examples/index.html +52 -47
- package/examples/platformer/gameCharacter.js +6 -2
- package/examples/platformer/gameLevel.js +1 -1
- package/examples/platformer/gameObjects.js +7 -5
- package/examples/shorts/blending.js +1 -1
- package/examples/shorts/landerGame.js +26 -2
- package/examples/shorts/music.js +3 -2
- package/examples/shorts/particles.js +11 -11
- package/examples/shorts/pongGame.js +0 -1
- package/examples/shorts/raycasting.js +4 -1
- package/examples/shorts/slidingPuzzle.js +13 -5
- package/examples/shorts/starfield.js +1 -1
- package/examples/shorts/uiSystem.js +0 -4
- package/examples/uiSystem/game.js +4 -4
- package/package.json +1 -1
- package/plugins/box2d.js +1 -1
- package/plugins/newgrounds.js +4 -4
- package/plugins/uiSystem.js +1 -1
- package/reference.md +0 -2
- package/src/engine.js +20 -12
- package/src/engineDebug.js +19 -17
- package/src/engineExport.js +1 -0
- package/src/engineInput.js +49 -22
- package/src/engineRelease.js +1 -0
- package/src/engineSettings.js +6 -0
- package/src/engineTileLayer.js +7 -1
- package/src/engineUtilities.js +12 -14
package/src/engineUtilities.js
CHANGED
|
@@ -217,7 +217,12 @@ function wave(frequency=1, amplitude=1, t=time, offset=0)
|
|
|
217
217
|
* @param {number} t - time in seconds
|
|
218
218
|
* @return {string}
|
|
219
219
|
* @memberof Utilities */
|
|
220
|
-
function formatTime(t)
|
|
220
|
+
function formatTime(t)
|
|
221
|
+
{
|
|
222
|
+
const sign = t < 0 ? '-' : '';
|
|
223
|
+
t = abs(t)|0;
|
|
224
|
+
return sign + (t/60|0) + ':' + (t%60<10?'0':'') + t%60;
|
|
225
|
+
}
|
|
221
226
|
|
|
222
227
|
/** Fetches a JSON file from a URL and returns the parsed JSON object. Must be used with await!
|
|
223
228
|
* @param {string} url - URL of JSON file
|
|
@@ -553,11 +558,7 @@ class Vector2
|
|
|
553
558
|
direction()
|
|
554
559
|
{ return abs(this.x) > abs(this.y) ? this.x < 0 ? 3 : 1 : this.y < 0 ? 2 : 0; }
|
|
555
560
|
|
|
556
|
-
/** Returns a copy of this vector
|
|
557
|
-
* @return {Vector2} */
|
|
558
|
-
invert() { return new Vector2(this.y, -this.x); }
|
|
559
|
-
|
|
560
|
-
/** Returns a copy of this vector absolute values
|
|
561
|
+
/** Returns a copy of this vector with absolute values
|
|
561
562
|
* @return {Vector2} */
|
|
562
563
|
abs() { return new Vector2(abs(this.x), abs(this.y)); }
|
|
563
564
|
|
|
@@ -599,13 +600,10 @@ class Vector2
|
|
|
599
600
|
toString(digits=3)
|
|
600
601
|
{
|
|
601
602
|
ASSERT_NUMBER_VALID(digits);
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
else
|
|
607
|
-
return `(${this.x}, ${this.y})`;
|
|
608
|
-
}
|
|
603
|
+
if (this.isValid())
|
|
604
|
+
return `(${(this.x<0?'':' ') + this.x.toFixed(digits)},${(this.y<0?'':' ') + this.y.toFixed(digits)} )`;
|
|
605
|
+
else
|
|
606
|
+
return `(${this.x}, ${this.y})`;
|
|
609
607
|
}
|
|
610
608
|
|
|
611
609
|
/** Checks if this is a valid vector
|
|
@@ -994,7 +992,7 @@ class Timer
|
|
|
994
992
|
|
|
995
993
|
/** Returns this timer expressed as a string
|
|
996
994
|
* @return {string} */
|
|
997
|
-
toString() {
|
|
995
|
+
toString() { return this.isSet() ? Math.abs(this.get()) + ' seconds ' + (this.get()<0 ? 'before' : 'after' ) : 'unset'; }
|
|
998
996
|
|
|
999
997
|
/** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
|
|
1000
998
|
* @return {number} */
|