pxt-common-packages 10.1.4 → 10.1.5

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.
Files changed (32) hide show
  1. package/libs/azureiot/built/debug/binary.js +461 -461
  2. package/libs/color/built/debug/binary.js +8 -8
  3. package/libs/color-sensor/built/debug/binary.js +8 -8
  4. package/libs/controller/built/debug/binary.js +4323 -4278
  5. package/libs/controller---none/built/debug/binary.js +8093 -8048
  6. package/libs/datalogger/built/debug/binary.js +63 -63
  7. package/libs/edge-connector/built/debug/binary.js +8 -8
  8. package/libs/esp32/built/debug/binary.js +462 -462
  9. package/libs/game/built/debug/binary.js +7323 -7278
  10. package/libs/game/hitbox.ts +42 -1
  11. package/libs/game/sprite.ts +5 -38
  12. package/libs/game/temp.d.ts +6 -0
  13. package/libs/game/tsconfig.json +21 -0
  14. package/libs/lcd/built/debug/binary.js +8 -8
  15. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  16. package/libs/lora/built/debug/binary.js +8 -8
  17. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  18. package/libs/mqtt/built/debug/binary.js +176 -176
  19. package/libs/net/built/debug/binary.js +176 -176
  20. package/libs/net-game/built/debug/binary.js +9687 -9642
  21. package/libs/palette/built/debug/binary.js +7885 -7840
  22. package/libs/pixel/built/debug/binary.js +8 -8
  23. package/libs/power/built/debug/binary.js +8 -8
  24. package/libs/proximity/built/debug/binary.js +8 -8
  25. package/libs/radio/built/debug/binary.js +8 -8
  26. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  27. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  28. package/libs/screen/built/debug/binary.js +50 -50
  29. package/libs/servo/built/debug/binary.js +8 -8
  30. package/libs/sprite-scaling/built/debug/binary.js +7885 -7840
  31. package/libs/storyboard/built/debug/binary.js +7885 -7840
  32. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  namespace game {
2
2
  export class Hitbox {
3
- hash: Fx8;
3
+ hash: number;
4
4
  parent: Sprite;
5
5
  ox: Fx8;
6
6
  oy: Fx8;
@@ -46,7 +46,48 @@ namespace game {
46
46
  return (x >= this.left) && (x <= this.right) && (y >= this.top) && (y <= this.bottom);
47
47
  }
48
48
 
49
+ updateIfInvalid() {
50
+ if (this.isValid())
51
+ return;
52
+
53
+ const newHitBox = game.calculateHitBox(this.parent);
54
+
55
+ const oMinX = this.ox;
56
+ const oMinY = this.oy;
57
+ const oMaxX = Fx.add(oMinX, this.width);
58
+ const oMaxY = Fx.add(oMinY, this.height);
59
+
60
+ const nMinX = newHitBox.ox;
61
+ const nMinY = newHitBox.oy;
62
+ const nMaxX = Fx.add(nMinX, newHitBox.width);
63
+ const nMaxY = Fx.add(nMinY, newHitBox.height);
64
+
65
+ // total diff in x / y corners between the two hitboxes
66
+ const xDiff = Fx.add(
67
+ Fx.abs(Fx.sub(oMinX, nMinX)),
68
+ Fx.abs(Fx.sub(oMaxX, nMaxX))
69
+ );
70
+ const yDiff = Fx.add(
71
+ Fx.abs(Fx.sub(oMinY, nMinY)),
72
+ Fx.abs(Fx.sub(oMaxY, nMaxY))
73
+ );
74
+
75
+ // If it's just a small change to the hitbox on one axis,
76
+ // don't change the dimensions to avoid random clipping
77
+ if (xDiff > Fx.twoFx8) {
78
+ this.ox = nMinX;
79
+ this.width = newHitBox.width;
80
+ }
81
+ if (yDiff > Fx.twoFx8) {
82
+ this.oy = nMinY;
83
+ this.height = newHitBox.height;
84
+ }
85
+ this.hash = newHitBox.hash;
86
+ }
87
+
49
88
  overlapsWith(other: Hitbox): boolean {
89
+ this.updateIfInvalid();
90
+ other.updateIfInvalid();
50
91
  if (this.contains(other.left, other.top)) return true;
51
92
  if (this.contains(other.left, other.bottom)) return true;
52
93
  if (this.contains(other.right, other.top)) return true;
@@ -337,7 +337,7 @@ class Sprite extends sprites.BaseSprite {
337
337
  }
338
338
 
339
339
  calcDimensionalHash() {
340
- return Fx.mul(Fx.mul(this._width, this._height), Fx8(this._image.revision()));
340
+ return this._image.revision() + Fx.toIntShifted(this._width, 8) + Fx.toIntShifted(this._height, 16);
341
341
  }
342
342
 
343
343
  resetHitbox() {
@@ -346,43 +346,10 @@ class Sprite extends sprites.BaseSprite {
346
346
  }
347
347
 
348
348
  setHitbox() {
349
- const newHitBox = game.calculateHitBox(this);
350
-
351
- if (!this._hitbox || this._hitbox.isValid()) {
352
- this._hitbox = newHitBox;
353
- return;
354
- }
355
-
356
- const oMinX = this._hitbox.ox;
357
- const oMinY = this._hitbox.oy;
358
- const oMaxX = Fx.add(oMinX, this._hitbox.width);
359
- const oMaxY = Fx.add(oMinY, this._hitbox.height);
360
-
361
- const nMinX = newHitBox.ox;
362
- const nMinY = newHitBox.oy;
363
- const nMaxX = Fx.add(nMinX, newHitBox.width);
364
- const nMaxY = Fx.add(nMinY, newHitBox.height);
365
-
366
- // total diff in x / y corners between the two hitboxes
367
- const xDiff = Fx.add(
368
- Fx.abs(Fx.sub(oMinX, nMinX)),
369
- Fx.abs(Fx.sub(oMaxX, nMaxX))
370
- );
371
- const yDiff = Fx.add(
372
- Fx.abs(Fx.sub(oMinY, nMinY)),
373
- Fx.abs(Fx.sub(oMaxY, nMaxY))
374
- );
375
-
376
- // If it's just a small change to the hitbox on one axis,
377
- // don't change the dimensions to avoid random clipping
378
- this._hitbox = newHitBox;
379
- if (xDiff <= Fx.twoFx8) {
380
- this._hitbox.ox = oMinX;
381
- this._hitbox.width = Fx.sub(oMaxX, oMinX);
382
- }
383
- if (yDiff <= Fx.twoFx8) {
384
- this._hitbox.oy = oMinY;
385
- this._hitbox.height = Fx.sub(oMaxY, oMinY);
349
+ if (this._hitbox) {
350
+ this._hitbox.updateIfInvalid();
351
+ } else {
352
+ this._hitbox = game.calculateHitBox(this);
386
353
  }
387
354
  }
388
355
 
@@ -36,4 +36,10 @@ declare namespace Math {
36
36
  function sign(x: number): number;
37
37
  }
38
38
 
39
+ declare interface Image {
40
+ revision(): number;
41
+ isStatic(): boolean;
42
+ equals(img: Image): boolean;
43
+ }
44
+
39
45
  declare const img: any;
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "noImplicitAny": true,
5
+ "noImplicitReturns": true,
6
+ "outDir": "../built",
7
+ "newLine": "LF",
8
+ "sourceMap": false,
9
+ "types": []
10
+ },
11
+ "include": [
12
+ "*.ts",
13
+ "../settings/*.ts",
14
+ "../screen/*.ts",
15
+ "../mixer/*.ts",
16
+ "../power/*.ts",
17
+ "../core/*.ts",
18
+ "../base/*.ts",
19
+ "../../../pxt/libs/pxt-common/*.ts"
20
+ ]
21
+ }
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48222(s) {
59
+ function _main___P48221(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___48465 = (undefined);
70
- globals._pollEventQueue___48478 = (undefined);
69
+ globals._intervals___48464 = (undefined);
70
+ globals._pollEventQueue___48477 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48222.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48222.continuations = [ ]
75
+ _main___P48221.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48221.continuations = [ ]
77
77
 
78
- function _main___P48222_mk(s) {
78
+ function _main___P48221_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48222, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48221, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P48222_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48222
91
+ return _main___P48221
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P96998(s) {
59
+ function _main___P96995(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___97241 = (undefined);
70
- globals._pollEventQueue___97254 = (undefined);
69
+ globals._intervals___97238 = (undefined);
70
+ globals._pollEventQueue___97251 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P96998.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P96998.continuations = [ ]
75
+ _main___P96995.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P96995.continuations = [ ]
77
77
 
78
- function _main___P96998_mk(s) {
78
+ function _main___P96995_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P96998, depth: s.depth + 1,
81
+ parent: s, fn: _main___P96995, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P96998_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P96998
91
+ return _main___P96995
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P59524(s) {
59
+ function _main___P59523(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___59767 = (undefined);
70
- globals._pollEventQueue___59780 = (undefined);
69
+ globals._intervals___59766 = (undefined);
70
+ globals._pollEventQueue___59779 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P59524.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P59524.continuations = [ ]
75
+ _main___P59523.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P59523.continuations = [ ]
77
77
 
78
- function _main___P59524_mk(s) {
78
+ function _main___P59523_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P59524, depth: s.depth + 1,
81
+ parent: s, fn: _main___P59523, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P59524_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P59524
91
+ return _main___P59523
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P188074(s) {
59
+ function _main___P188067(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___188317 = (undefined);
70
- globals._pollEventQueue___188330 = (undefined);
69
+ globals._intervals___188310 = (undefined);
70
+ globals._pollEventQueue___188323 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P188074.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P188074.continuations = [ ]
75
+ _main___P188067.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P188067.continuations = [ ]
77
77
 
78
- function _main___P188074_mk(s) {
78
+ function _main___P188067_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P188074, depth: s.depth + 1,
81
+ parent: s, fn: _main___P188067, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P188074_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P188074
91
+ return _main___P188067
92
92
  })