squishjs 0.7.56 → 0.7.62

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/index.js CHANGED
@@ -12,6 +12,7 @@ const subtypes = require('./src/subtypes');
12
12
  const Squisher = require('./src/Squisher');
13
13
  const Asset = require('./src/Asset');
14
14
  const GeometryUtils = require('./src/util/geometry');
15
+ const Physics = require('./src/physics');
15
16
 
16
17
  module.exports = {
17
18
  squish,
@@ -28,5 +29,6 @@ module.exports = {
28
29
  ViewUtils: viewUtils,
29
30
  TerrainGenerator: terrainGenerator,
30
31
  GeometryUtils,
31
- Asset
32
+ Asset,
33
+ Physics
32
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squishjs",
3
- "version": "0.7.56",
3
+ "version": "0.7.62",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
package/src/Asset.js CHANGED
@@ -5,8 +5,7 @@ class Asset {
5
5
  this.data = data;
6
6
  }
7
7
 
8
-
9
- console.log('ayyyy lmao doing this sdf')
8
+ // this is dumb. was trying something but made it dumb.
10
9
  this.https = require('https');
11
10
  this.http = require('http');
12
11
  this.fs = require('fs');
package/src/physics.js ADDED
@@ -0,0 +1,42 @@
1
+ const Physics = {
2
+ getPath: (startX, startY, xVel, yVel, endX = 100, endY = 100) => {
3
+ const path = [];
4
+ let withinEdges = true;
5
+ while (withinEdges) {
6
+ const curX = path.length === 0 ? startX : path[path.length - 1][0];
7
+ const curY = path.length === 0 ? startY : path[path.length - 1][1];
8
+
9
+ const newX = curX + xVel;
10
+ const newY = curY + yVel;
11
+
12
+ if (newX < 0 || newX > endX || newY < 0 || newY > endY) {
13
+ let _newX = newX;
14
+ let _newY = newY;
15
+ if (newX < 0) {
16
+ _newX = 0;
17
+ } else if (newX > endX) {
18
+ _newX = endX;
19
+ }
20
+
21
+ if (newY < 0) {
22
+ _newY = 0;
23
+ } else if (newY > endY) {
24
+ _newY = endY;
25
+ }
26
+
27
+ if (!(path[path.length - 1][0] === _newX || path[path.length - 1][1] === _newY)) {
28
+ path.push([_newX, _newY]);
29
+ }
30
+
31
+ withinEdges = false;
32
+ } else {
33
+ path.push([newX, newY]);
34
+ }
35
+ }
36
+
37
+ return path;
38
+ }
39
+ };
40
+
41
+ module.exports = Physics;
42
+