littlejsengine 1.17.14 → 1.17.15

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.
@@ -35,7 +35,7 @@ const engineName = 'LittleJS';
35
35
  * @type {string}
36
36
  * @default
37
37
  * @memberof Engine */
38
- const engineVersion = '1.17.14';
38
+ const engineVersion = '1.17.15';
39
39
 
40
40
  /** Frames per second to update
41
41
  * @type {number}
@@ -1087,15 +1087,17 @@ function lineTest(posStart, posEnd, testFunction, normal)
1087
1087
  // set hit point
1088
1088
  const hitPos = vec2(posStart.x + dirX*t, posStart.y + dirY*t);
1089
1089
 
1090
- // move inside of tile if on positive edge
1090
+ // ensure result is inside the tile
1091
1091
  const e = 1e-9;
1092
- if (wasX)
1093
- {
1094
- if (stepX < 0)
1095
- hitPos.x -= e;
1096
- }
1097
- else if (stepY < 0)
1098
- hitPos.y -= e;
1092
+ const hitPosFloor = hitPos.floor();
1093
+ if (hitPosFloor.x < pos.x)
1094
+ hitPos.x = pos.x;
1095
+ else if (hitPosFloor.x > pos.x)
1096
+ hitPos.x = pos.x + 1 - e;
1097
+ if (hitPosFloor.y < pos.y)
1098
+ hitPos.y = pos.y;
1099
+ else if (hitPosFloor.y > pos.y)
1100
+ hitPos.y = pos.y + 1 - e;
1099
1101
 
1100
1102
  // set normal
1101
1103
  if (normal)
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html><meta charset=utf-8><body>
2
- <script src=../../dist/littlejs.js?1.17.14></script>
2
+ <script src=../../dist/littlejs.js?1.17.15></script>
3
3
  <script src=../../dist/box2d.wasm.js></script>
4
4
 
5
5
  <!-- LittleJS Engine Source
@@ -7,7 +7,7 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- LittleJS Engine -->
10
- <script src=../../dist/littlejs.js?1.17.14></script>
10
+ <script src=../../dist/littlejs.js?1.17.15></script>
11
11
 
12
12
  <!-- LittleJS Engine Source
13
13
  <script src=../../src/engine.js></script>
@@ -32,4 +32,4 @@
32
32
  -->
33
33
 
34
34
  <!-- Add your game scripts here -->
35
- <script src=game.js?1.17.14></script>
35
+ <script src=game.js?1.17.15></script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littlejsengine",
3
- "version": "1.17.14",
3
+ "version": "1.17.15",
4
4
  "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
5
  "main": "dist/littlejs.esm.js",
6
6
  "types": "dist/littlejs.d.ts",
package/src/engine.js CHANGED
@@ -32,7 +32,7 @@ const engineName = 'LittleJS';
32
32
  * @type {string}
33
33
  * @default
34
34
  * @memberof Engine */
35
- const engineVersion = '1.17.14';
35
+ const engineVersion = '1.17.15';
36
36
 
37
37
  /** Frames per second to update
38
38
  * @type {number}
package/src/engineMath.js CHANGED
@@ -360,15 +360,17 @@ function lineTest(posStart, posEnd, testFunction, normal)
360
360
  // set hit point
361
361
  const hitPos = vec2(posStart.x + dirX*t, posStart.y + dirY*t);
362
362
 
363
- // move inside of tile if on positive edge
363
+ // ensure result is inside the tile
364
364
  const e = 1e-9;
365
- if (wasX)
366
- {
367
- if (stepX < 0)
368
- hitPos.x -= e;
369
- }
370
- else if (stepY < 0)
371
- hitPos.y -= e;
365
+ const hitPosFloor = hitPos.floor();
366
+ if (hitPosFloor.x < pos.x)
367
+ hitPos.x = pos.x;
368
+ else if (hitPosFloor.x > pos.x)
369
+ hitPos.x = pos.x + 1 - e;
370
+ if (hitPosFloor.y < pos.y)
371
+ hitPos.y = pos.y;
372
+ else if (hitPosFloor.y > pos.y)
373
+ hitPos.y = pos.y + 1 - e;
372
374
 
373
375
  // set normal
374
376
  if (normal)