pxt-common-packages 9.4.13 → 9.4.16

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 (39) hide show
  1. package/built/common-sim.d.ts +44 -0
  2. package/built/common-sim.js +202 -63
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color-sensor/built/debug/binary.js +8 -8
  6. package/libs/controller/built/debug/binary.js +8290 -8027
  7. package/libs/controller---none/built/debug/binary.js +8269 -8006
  8. package/libs/datalogger/built/debug/binary.js +63 -63
  9. package/libs/edge-connector/built/debug/binary.js +8 -8
  10. package/libs/esp32/built/debug/binary.js +462 -462
  11. package/libs/game/_locales/game-jsdoc-strings.json +19 -0
  12. package/libs/game/_locales/game-strings.json +2 -0
  13. package/libs/game/built/debug/binary.js +8182 -7919
  14. package/libs/game/extendableSprite.ts +80 -0
  15. package/libs/game/hitbox.ts +42 -1
  16. package/libs/game/keymap.cpp +12 -0
  17. package/libs/game/keymap.ts +169 -0
  18. package/libs/game/pxt.json +4 -1
  19. package/libs/game/sim/keymap.ts +167 -0
  20. package/libs/game/sprite.ts +73 -95
  21. package/libs/lcd/built/debug/binary.js +8 -8
  22. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  23. package/libs/lora/built/debug/binary.js +8 -8
  24. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  25. package/libs/mqtt/built/debug/binary.js +176 -176
  26. package/libs/net/built/debug/binary.js +176 -176
  27. package/libs/net-game/built/debug/binary.js +9970 -9707
  28. package/libs/palette/built/debug/binary.js +8181 -7918
  29. package/libs/pixel/built/debug/binary.js +8 -8
  30. package/libs/power/built/debug/binary.js +8 -8
  31. package/libs/proximity/built/debug/binary.js +8 -8
  32. package/libs/radio/built/debug/binary.js +8 -8
  33. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  34. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  35. package/libs/screen/built/debug/binary.js +50 -50
  36. package/libs/servo/built/debug/binary.js +8 -8
  37. package/libs/sprite-scaling/built/debug/binary.js +8181 -7918
  38. package/libs/storyboard/built/debug/binary.js +8181 -7918
  39. package/package.json +1 -1
@@ -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
 
@@ -394,7 +361,7 @@ class Sprite extends sprites.BaseSprite {
394
361
  return !(this.flags & SpriteFlag.Invisible);
395
362
  }
396
363
 
397
- private recalcSize(): void {
364
+ protected recalcSize(): void {
398
365
  this._width = Fx8(this._image.width * this.sx);
399
366
  this._height = Fx8(this._image.height * this.sy);
400
367
  this.resetHitbox();
@@ -645,21 +612,7 @@ class Sprite extends sprites.BaseSprite {
645
612
  }
646
613
 
647
614
  __drawCore(camera: scene.Camera) {
648
- if (this.sayRenderer) {
649
- if (this.sayEndTime !== undefined) {
650
- if (control.millis() < this.sayEndTime) {
651
- this.sayRenderer.draw(screen, camera, this);
652
- }
653
- else {
654
- this.sayRenderer.destroy();
655
- this.sayRenderer = undefined;
656
- this.sayEndTime = undefined;
657
- }
658
- }
659
- else {
660
- this.sayRenderer.draw(screen, camera, this)
661
- }
662
- }
615
+ this.drawSay(camera);
663
616
 
664
617
  if (this.isOutOfScreen(camera)) return;
665
618
 
@@ -669,47 +622,8 @@ class Sprite extends sprites.BaseSprite {
669
622
  const l = Math.floor(this.left - ox);
670
623
  const t = Math.floor(this.top - oy);
671
624
 
672
- if (!this.isScaled())
673
- screen.drawTransparentImage(this._image, l, t);
674
- else
675
- screen.blit(
676
- // dst rect in screen
677
- l, t,
678
- this.width,
679
- this.height,
680
- // src rect in sprite image
681
- this._image,
682
- 0, 0,
683
- this._image.width, this._image.height,
684
- true, false);
685
-
686
- if (this.flags & SpriteFlag.ShowPhysics) {
687
- const font = image.font5;
688
- const margin = 2;
689
- let tx = l;
690
- let ty = t + this.height + margin;
691
- screen.print(`${this.x >> 0},${this.y >> 0}`, tx, ty, 1, font);
692
- tx -= font.charWidth;
693
- if (this.vx || this.vy) {
694
- ty += font.charHeight + margin;
695
- screen.print(`v${this.vx >> 0},${this.vy >> 0}`, tx, ty, 1, font);
696
- }
697
- if (this.ax || this.ay) {
698
- ty += font.charHeight + margin;
699
- screen.print(`a${this.ax >> 0},${this.ay >> 0}`, tx, ty, 1, font);
700
- }
701
- }
702
-
703
- // debug info
704
- if (game.debug) {
705
- screen.drawRect(
706
- Fx.toInt(this._hitbox.left) - ox,
707
- Fx.toInt(this._hitbox.top) - oy,
708
- Fx.toInt(this._hitbox.width),
709
- Fx.toInt(this._hitbox.height),
710
- 1
711
- );
712
- }
625
+ this.drawSprite(l, t);
626
+ this.drawDebug(l, t, ox, oy);
713
627
  }
714
628
 
715
629
  __update(camera: scene.Camera, dt: number) {
@@ -1170,4 +1084,68 @@ class Sprite extends sprites.BaseSprite {
1170
1084
  toString() {
1171
1085
  return `${this.id}(${this.x},${this.y})->(${this.vx},${this.vy})`;
1172
1086
  }
1087
+
1088
+ protected drawSay(camera: scene.Camera) {
1089
+ if (this.sayRenderer) {
1090
+ if (this.sayEndTime !== undefined) {
1091
+ if (control.millis() < this.sayEndTime) {
1092
+ this.sayRenderer.draw(screen, camera, this);
1093
+ }
1094
+ else {
1095
+ this.sayRenderer.destroy();
1096
+ this.sayRenderer = undefined;
1097
+ this.sayEndTime = undefined;
1098
+ }
1099
+ }
1100
+ else {
1101
+ this.sayRenderer.draw(screen, camera, this)
1102
+ }
1103
+ }
1104
+ }
1105
+
1106
+ protected drawDebug(left: number, top: number, offsetX: number, offsetY: number) {
1107
+ if (this.flags & SpriteFlag.ShowPhysics) {
1108
+ const font = image.font5;
1109
+ const margin = 2;
1110
+ let tx = left;
1111
+ let ty = top + this.height + margin;
1112
+ screen.print(`${this.x >> 0},${this.y >> 0}`, tx, ty, 1, font);
1113
+ tx -= font.charWidth;
1114
+ if (this.vx || this.vy) {
1115
+ ty += font.charHeight + margin;
1116
+ screen.print(`v${this.vx >> 0},${this.vy >> 0}`, tx, ty, 1, font);
1117
+ }
1118
+ if (this.ax || this.ay) {
1119
+ ty += font.charHeight + margin;
1120
+ screen.print(`a${this.ax >> 0},${this.ay >> 0}`, tx, ty, 1, font);
1121
+ }
1122
+ }
1123
+
1124
+ // debug info
1125
+ if (game.debug) {
1126
+ screen.drawRect(
1127
+ Fx.toInt(this._hitbox.left) - offsetX,
1128
+ Fx.toInt(this._hitbox.top) - offsetY,
1129
+ Fx.toInt(this._hitbox.width),
1130
+ Fx.toInt(this._hitbox.height),
1131
+ 1
1132
+ );
1133
+ }
1134
+ }
1135
+
1136
+ protected drawSprite(drawLeft: number, drawTop: number) {
1137
+ if (!this.isScaled())
1138
+ screen.drawTransparentImage(this._image, drawLeft, drawTop);
1139
+ else
1140
+ screen.blit(
1141
+ // dst rect in screen
1142
+ drawLeft, drawTop,
1143
+ this.width,
1144
+ this.height,
1145
+ // src rect in sprite image
1146
+ this._image,
1147
+ 0, 0,
1148
+ this._image.width, this._image.height,
1149
+ true, false);
1150
+ }
1173
1151
  }
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48926(s) {
59
+ function _main___P48208(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___49169 = (undefined);
70
- globals._pollEventQueue___49182 = (undefined);
69
+ globals._intervals___48451 = (undefined);
70
+ globals._pollEventQueue___48464 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48926.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48926.continuations = [ ]
75
+ _main___P48208.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48208.continuations = [ ]
77
77
 
78
- function _main___P48926_mk(s) {
78
+ function _main___P48208_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48926, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48208, 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___P48926_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48926
91
+ return _main___P48208
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___P97394(s) {
59
+ function _main___P96956(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___97637 = (undefined);
70
- globals._pollEventQueue___97650 = (undefined);
69
+ globals._intervals___97199 = (undefined);
70
+ globals._pollEventQueue___97212 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P97394.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P97394.continuations = [ ]
75
+ _main___P96956.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P96956.continuations = [ ]
77
77
 
78
- function _main___P97394_mk(s) {
78
+ function _main___P96956_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P97394, depth: s.depth + 1,
81
+ parent: s, fn: _main___P96956, 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___P97394_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P97394
91
+ return _main___P96956
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___P60228(s) {
59
+ function _main___P59510(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___60471 = (undefined);
70
- globals._pollEventQueue___60484 = (undefined);
69
+ globals._intervals___59753 = (undefined);
70
+ globals._pollEventQueue___59766 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P60228.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P60228.continuations = [ ]
75
+ _main___P59510.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P59510.continuations = [ ]
77
77
 
78
- function _main___P60228_mk(s) {
78
+ function _main___P59510_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P60228, depth: s.depth + 1,
81
+ parent: s, fn: _main___P59510, 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___P60228_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P60228
91
+ return _main___P59510
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___P188708(s) {
59
+ function _main___P187972(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___188951 = (undefined);
70
- globals._pollEventQueue___188964 = (undefined);
69
+ globals._intervals___188215 = (undefined);
70
+ globals._pollEventQueue___188228 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P188708.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P188708.continuations = [ ]
75
+ _main___P187972.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P187972.continuations = [ ]
77
77
 
78
- function _main___P188708_mk(s) {
78
+ function _main___P187972_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P188708, depth: s.depth + 1,
81
+ parent: s, fn: _main___P187972, 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___P188708_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P188708
91
+ return _main___P187972
92
92
  })