pxt-common-packages 9.5.9 → 9.5.10

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 +7877 -7659
  5. package/libs/controller---none/built/debug/binary.js +7854 -7636
  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/_locales/game-jsdoc-strings.json +5 -0
  10. package/libs/game/built/debug/binary.js +7769 -7551
  11. package/libs/game/extendableSprite.ts +80 -0
  12. package/libs/game/pxt.json +1 -0
  13. package/libs/game/sprite.ts +68 -57
  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 +9557 -9339
  21. package/libs/palette/built/debug/binary.js +7768 -7550
  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 +7768 -7550
  31. package/libs/storyboard/built/debug/binary.js +7768 -7550
  32. package/package.json +1 -1
@@ -0,0 +1,80 @@
1
+ namespace sprites {
2
+ /**
3
+ * A version of the Sprite class that is easier to extend.
4
+ *
5
+ * Unlike the normal Sprite class, this class will automatically add
6
+ * itself to the physics engine and run all sprite created handlers
7
+ * in the constructor
8
+ */
9
+ export class ExtendableSprite extends Sprite {
10
+ protected hasCustomDimensions: boolean;
11
+
12
+ constructor(spriteImage: Image, kind?: number) {
13
+ super(spriteImage);
14
+
15
+ const scene = game.currentScene();
16
+ this.setKind(kind);
17
+ scene.physicsEngine.addSprite(this);
18
+
19
+ // run on created handlers
20
+ scene.createdHandlers
21
+ .filter(h => h.kind == kind)
22
+ .forEach(h => h.handler(this));
23
+
24
+ this.hasCustomDimensions = false;
25
+ }
26
+
27
+ /**
28
+ * Override to change how the sprite is drawn to the screen
29
+ *
30
+ * @param drawLeft The left position to draw the sprite at (already adjusted for camera)
31
+ * @param drawTop The top position to draw the sprite at (already adjusted for camera)
32
+ */
33
+ draw(drawLeft: number, drawTop: number) {
34
+ super.drawSprite(drawLeft, drawTop);
35
+ }
36
+
37
+ /**
38
+ * Override to add update logic for a sprite. This method runs once per frame
39
+ *
40
+ * @param deltaTimeMillis The time that has elapsed since the last frame in milliseconds
41
+ */
42
+ update(deltaTimeMillis: number) {
43
+ }
44
+
45
+ /**
46
+ * Sets the width and height of this sprite. Once set, this will also prevent
47
+ * this width and height from automatically changing whenever scale or the image
48
+ * changes
49
+ */
50
+ setDimensions(width: number, height: number) {
51
+ this._width = Fx8(width);
52
+ this._height = Fx8(height);
53
+ this.hasCustomDimensions = true;
54
+ this.resetHitbox();
55
+ }
56
+
57
+ __update(camera: scene.Camera, dt: number) {
58
+ super.__update(camera, dt);
59
+ this.update(game.currentScene().eventContext.deltaTimeMillis)
60
+ }
61
+
62
+ setHitbox() {
63
+ if (this.hasCustomDimensions) {
64
+ this._hitbox = new game.Hitbox(this, this._width, this._height, Fx.zeroFx8, Fx.zeroFx8)
65
+ }
66
+ else {
67
+ super.setHitbox();
68
+ }
69
+ }
70
+
71
+ protected drawSprite(drawLeft: number, drawTop: number): void {
72
+ this.draw(drawLeft, drawTop);
73
+ }
74
+
75
+ protected recalcSize() {
76
+ if (this.hasCustomDimensions) return;
77
+ super.recalcSize();
78
+ }
79
+ }
80
+ }
@@ -13,6 +13,7 @@
13
13
  "spritesay.ts",
14
14
  "sprites.ts",
15
15
  "sprite.ts",
16
+ "extendableSprite.ts",
16
17
  "sprite.d.ts",
17
18
  "spritemap.ts",
18
19
  "spriteevents.ts",
@@ -394,7 +394,7 @@ class Sprite extends sprites.BaseSprite {
394
394
  return !(this.flags & SpriteFlag.Invisible);
395
395
  }
396
396
 
397
- private recalcSize(): void {
397
+ protected recalcSize(): void {
398
398
  this._width = Fx8(this._image.width * this.sx);
399
399
  this._height = Fx8(this._image.height * this.sy);
400
400
  this.resetHitbox();
@@ -645,21 +645,7 @@ class Sprite extends sprites.BaseSprite {
645
645
  }
646
646
 
647
647
  __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
- }
648
+ this.drawSay(camera);
663
649
 
664
650
  if (this.isOutOfScreen(camera)) return;
665
651
 
@@ -669,47 +655,8 @@ class Sprite extends sprites.BaseSprite {
669
655
  const l = Math.floor(this.left - ox);
670
656
  const t = Math.floor(this.top - oy);
671
657
 
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
- }
658
+ this.drawSprite(l, t);
659
+ this.drawDebug(l, t, ox, oy);
713
660
  }
714
661
 
715
662
  __update(camera: scene.Camera, dt: number) {
@@ -1171,4 +1118,68 @@ class Sprite extends sprites.BaseSprite {
1171
1118
  toString() {
1172
1119
  return `${this.id}(${this.x},${this.y})->(${this.vx},${this.vy})`;
1173
1120
  }
1121
+
1122
+ protected drawSay(camera: scene.Camera) {
1123
+ if (this.sayRenderer) {
1124
+ if (this.sayEndTime !== undefined) {
1125
+ if (control.millis() < this.sayEndTime) {
1126
+ this.sayRenderer.draw(screen, camera, this);
1127
+ }
1128
+ else {
1129
+ this.sayRenderer.destroy();
1130
+ this.sayRenderer = undefined;
1131
+ this.sayEndTime = undefined;
1132
+ }
1133
+ }
1134
+ else {
1135
+ this.sayRenderer.draw(screen, camera, this)
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ protected drawDebug(left: number, top: number, offsetX: number, offsetY: number) {
1141
+ if (this.flags & SpriteFlag.ShowPhysics) {
1142
+ const font = image.font5;
1143
+ const margin = 2;
1144
+ let tx = left;
1145
+ let ty = top + this.height + margin;
1146
+ screen.print(`${this.x >> 0},${this.y >> 0}`, tx, ty, 1, font);
1147
+ tx -= font.charWidth;
1148
+ if (this.vx || this.vy) {
1149
+ ty += font.charHeight + margin;
1150
+ screen.print(`v${this.vx >> 0},${this.vy >> 0}`, tx, ty, 1, font);
1151
+ }
1152
+ if (this.ax || this.ay) {
1153
+ ty += font.charHeight + margin;
1154
+ screen.print(`a${this.ax >> 0},${this.ay >> 0}`, tx, ty, 1, font);
1155
+ }
1156
+ }
1157
+
1158
+ // debug info
1159
+ if (game.debug) {
1160
+ screen.drawRect(
1161
+ Fx.toInt(this._hitbox.left) - offsetX,
1162
+ Fx.toInt(this._hitbox.top) - offsetY,
1163
+ Fx.toInt(this._hitbox.width),
1164
+ Fx.toInt(this._hitbox.height),
1165
+ 1
1166
+ );
1167
+ }
1168
+ }
1169
+
1170
+ protected drawSprite(drawLeft: number, drawTop: number) {
1171
+ if (!this.isScaled())
1172
+ screen.drawTransparentImage(this._image, drawLeft, drawTop);
1173
+ else
1174
+ screen.blit(
1175
+ // dst rect in screen
1176
+ drawLeft, drawTop,
1177
+ this.width,
1178
+ this.height,
1179
+ // src rect in sprite image
1180
+ this._image,
1181
+ 0, 0,
1182
+ this._image.width, this._image.height,
1183
+ true, false);
1184
+ }
1174
1185
  }
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48182(s) {
59
+ function _main___P48216(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___48425 = (undefined);
70
- globals._pollEventQueue___48438 = (undefined);
69
+ globals._intervals___48459 = (undefined);
70
+ globals._pollEventQueue___48472 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48182.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48182.continuations = [ ]
75
+ _main___P48216.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48216.continuations = [ ]
77
77
 
78
- function _main___P48182_mk(s) {
78
+ function _main___P48216_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48182, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48216, 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___P48182_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48182
91
+ return _main___P48216
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___P96878(s) {
59
+ function _main___P96980(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___97121 = (undefined);
70
- globals._pollEventQueue___97134 = (undefined);
69
+ globals._intervals___97223 = (undefined);
70
+ globals._pollEventQueue___97236 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P96878.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P96878.continuations = [ ]
75
+ _main___P96980.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P96980.continuations = [ ]
77
77
 
78
- function _main___P96878_mk(s) {
78
+ function _main___P96980_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P96878, depth: s.depth + 1,
81
+ parent: s, fn: _main___P96980, 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___P96878_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P96878
91
+ return _main___P96980
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___P59484(s) {
59
+ function _main___P59518(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___59727 = (undefined);
70
- globals._pollEventQueue___59740 = (undefined);
69
+ globals._intervals___59761 = (undefined);
70
+ globals._pollEventQueue___59774 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P59484.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P59484.continuations = [ ]
75
+ _main___P59518.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P59518.continuations = [ ]
77
77
 
78
- function _main___P59484_mk(s) {
78
+ function _main___P59518_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P59484, depth: s.depth + 1,
81
+ parent: s, fn: _main___P59518, 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___P59484_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P59484
91
+ return _main___P59518
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___P187794(s) {
59
+ function _main___P188032(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___188037 = (undefined);
70
- globals._pollEventQueue___188050 = (undefined);
69
+ globals._intervals___188275 = (undefined);
70
+ globals._pollEventQueue___188288 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P187794.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P187794.continuations = [ ]
75
+ _main___P188032.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P188032.continuations = [ ]
77
77
 
78
- function _main___P187794_mk(s) {
78
+ function _main___P188032_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P187794, depth: s.depth + 1,
81
+ parent: s, fn: _main___P188032, 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___P187794_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P187794
91
+ return _main___P188032
92
92
  })