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.
@@ -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) { return (t/60|0) + ':' + (t%60<10?'0':'') + (t%60|0); }
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 that has been inverted
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 (debug)
603
- {
604
- if (this.isValid())
605
- return `(${(this.x<0?'':' ') + this.x.toFixed(digits)},${(this.y<0?'':' ') + this.y.toFixed(digits)} )`;
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() { if (debug) { return this.isSet() ? Math.abs(this.get()) + ' seconds ' + (this.get()<0 ? 'before' : 'after' ) : 'unset'; }}
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} */