pxt-common-packages 10.3.21 → 10.3.23

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 (40) hide show
  1. package/built/common-sim.d.ts +14 -2
  2. package/built/common-sim.js +83 -29
  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 +7986 -7953
  7. package/libs/controller---none/built/debug/binary.js +7965 -7932
  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/built/debug/binary.js +7878 -7845
  12. package/libs/game/info.ts +18 -8
  13. package/libs/game/sprite.ts +2 -0
  14. package/libs/game/sprites.ts +1 -0
  15. package/libs/lcd/built/debug/binary.js +8 -8
  16. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  17. package/libs/lora/built/debug/binary.js +8 -8
  18. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  19. package/libs/microphone/sim/state.ts +24 -1
  20. package/libs/mqtt/built/debug/binary.js +176 -176
  21. package/libs/multiplayer/player.ts +1 -0
  22. package/libs/net/built/debug/binary.js +176 -176
  23. package/libs/net-game/built/debug/binary.js +9666 -9633
  24. package/libs/palette/built/debug/binary.js +7877 -7844
  25. package/libs/pixel/built/debug/binary.js +8 -8
  26. package/libs/power/built/debug/binary.js +8 -8
  27. package/libs/proximity/built/debug/binary.js +8 -8
  28. package/libs/radio/built/debug/binary.js +8 -8
  29. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  30. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  31. package/libs/screen/built/debug/binary.js +50 -50
  32. package/libs/screen/sim/image.ts +32 -31
  33. package/libs/servo/built/debug/binary.js +8 -8
  34. package/libs/shader/pxt.json +14 -0
  35. package/libs/shader/shader.cpp +140 -0
  36. package/libs/shader/shader.ts +19 -0
  37. package/libs/shader/sim/shader.ts +37 -0
  38. package/libs/sprite-scaling/built/debug/binary.js +7877 -7844
  39. package/libs/storyboard/built/debug/binary.js +7877 -7844
  40. package/package.json +1 -1
package/libs/game/info.ts CHANGED
@@ -33,7 +33,7 @@ namespace info {
33
33
  // null: reached 0 and callback was invoked
34
34
  public life: number;
35
35
  public lifeZeroHandler: () => void;
36
- public scoreReachedHandler: ScoreReachedHandler
36
+ public scoreReachedHandlers: ScoreReachedHandler[];
37
37
 
38
38
  public showScore?: boolean;
39
39
  public showLife?: boolean;
@@ -45,6 +45,7 @@ namespace info {
45
45
  this.showScore = undefined;
46
46
  this.showLife = undefined;
47
47
  this.showPlayer = undefined;
48
+ this.scoreReachedHandlers = [];
48
49
  }
49
50
  }
50
51
 
@@ -711,12 +712,12 @@ namespace info {
711
712
  const oldScore = state.score || 0;
712
713
  state.score = (value | 0);
713
714
 
714
- if (state.scoreReachedHandler && (
715
- (oldScore < state.scoreReachedHandler.score && state.score >= state.scoreReachedHandler.score) ||
716
- (oldScore > state.scoreReachedHandler.score && state.score <= state.scoreReachedHandler.score)
717
- )) {
718
- state.scoreReachedHandler.handler();
719
- }
715
+ state.scoreReachedHandlers.forEach(srh => {
716
+ if ((oldScore < srh.score && state.score >= srh.score) ||
717
+ (oldScore > srh.score && state.score <= srh.score)) {
718
+ srh.handler();
719
+ }
720
+ });
720
721
  }
721
722
 
722
723
  changeScoreBy(value: number): void {
@@ -766,7 +767,16 @@ namespace info {
766
767
 
767
768
  onScore(score: number, handler: () => void) {
768
769
  const state = this.getState();
769
- state.scoreReachedHandler = new ScoreReachedHandler(score, handler);
770
+
771
+ for (const element of state.scoreReachedHandlers) {
772
+ if (element.score === score) {
773
+ // Score handlers are implemented as "last one wins."
774
+ element.handler = handler;
775
+ return;
776
+ }
777
+ }
778
+
779
+ state.scoreReachedHandlers.push(new ScoreReachedHandler(score, handler));
770
780
  }
771
781
 
772
782
  raiseLifeZero(gameOver: boolean) {
@@ -694,6 +694,8 @@ class Sprite extends sprites.BaseSprite {
694
694
  return false
695
695
  if (other.flags & SPRITE_NO_SPRITE_OVERLAPS)
696
696
  return false
697
+ if (this.flags & sprites.Flag.HitboxOverlaps || other.flags & sprites.Flag.HitboxOverlaps)
698
+ return other._hitbox.overlapsWith(this._hitbox);
697
699
  if (!other._hitbox.overlapsWith(this._hitbox))
698
700
  return false;
699
701
  if (!this.isScaled() && !other.isScaled()) {
@@ -196,6 +196,7 @@ namespace sprites {
196
196
  GhostThroughTiles = 1 << 10, // No overlaps with tiles
197
197
  GhostThroughWalls = 1 << 11, // No collisions with walls
198
198
  GhostThroughSprites = 1 << 12, // No overlaps with other sprites
199
+ HitboxOverlaps = 1 << 13, // If set, overlaps with this sprite are based off of both sprites' hitboxes and not pixel perfect
199
200
  Ghost = sprites.Flag.GhostThroughSprites | sprites.Flag.GhostThroughWalls | sprites.Flag.GhostThroughTiles, // doesn't collide with other sprites or walls
200
201
  }
201
202
  }
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48866(s) {
59
+ function _main___P48881(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___49109 = (undefined);
70
- globals._pollEventQueue___49122 = (undefined);
69
+ globals._intervals___49124 = (undefined);
70
+ globals._pollEventQueue___49137 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48866.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48866.continuations = [ ]
75
+ _main___P48881.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48881.continuations = [ ]
77
77
 
78
- function _main___P48866_mk(s) {
78
+ function _main___P48881_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48866, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48881, 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___P48866_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48866
91
+ return _main___P48881
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___P98936(s) {
59
+ function _main___P98981(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___99179 = (undefined);
70
- globals._pollEventQueue___99192 = (undefined);
69
+ globals._intervals___99224 = (undefined);
70
+ globals._pollEventQueue___99237 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P98936.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P98936.continuations = [ ]
75
+ _main___P98981.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P98981.continuations = [ ]
77
77
 
78
- function _main___P98936_mk(s) {
78
+ function _main___P98981_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P98936, depth: s.depth + 1,
81
+ parent: s, fn: _main___P98981, 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___P98936_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P98936
91
+ return _main___P98981
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___P60174(s) {
59
+ function _main___P60189(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___60417 = (undefined);
70
- globals._pollEventQueue___60430 = (undefined);
69
+ globals._intervals___60432 = (undefined);
70
+ globals._pollEventQueue___60445 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P60174.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P60174.continuations = [ ]
75
+ _main___P60189.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P60189.continuations = [ ]
77
77
 
78
- function _main___P60174_mk(s) {
78
+ function _main___P60189_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P60174, depth: s.depth + 1,
81
+ parent: s, fn: _main___P60189, 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___P60174_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P60174
91
+ return _main___P60189
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___P192588(s) {
59
+ function _main___P192693(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___192831 = (undefined);
70
- globals._pollEventQueue___192844 = (undefined);
69
+ globals._intervals___192936 = (undefined);
70
+ globals._pollEventQueue___192949 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P192588.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P192588.continuations = [ ]
75
+ _main___P192693.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P192693.continuations = [ ]
77
77
 
78
- function _main___P192588_mk(s) {
78
+ function _main___P192693_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P192588, depth: s.depth + 1,
81
+ parent: s, fn: _main___P192693, 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___P192588_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P192588
91
+ return _main___P192693
92
92
  })
@@ -1,6 +1,29 @@
1
+ /// <reference path="../../core/sim/analogSensor.ts" />
2
+
1
3
  namespace pxsim {
2
4
  export interface MicrophoneBoard {
3
- microphoneState: AnalogSensorState;
5
+ microphoneState: MicrophoneState;
6
+ }
7
+
8
+ export class MicrophoneState extends AnalogSensorState {
9
+ public onSoundRegistered: boolean = false;
10
+ public soundLevelRequested: boolean = false;
11
+ private pingUsed: ReturnType<typeof setTimeout>;
12
+
13
+ public pingSoundLevel = () => {
14
+ if (this.onSoundRegistered) {
15
+ return;
16
+ }
17
+ this.soundLevelRequested = true;
18
+ runtime.queueDisplayUpdate();
19
+ clearTimeout(this.pingUsed);
20
+ this.pingUsed = setTimeout(() => {
21
+ this.soundLevelRequested = false;
22
+ runtime.queueDisplayUpdate();
23
+ this.pingUsed = undefined;
24
+ }, 100);
25
+ }
26
+
4
27
  }
5
28
 
6
29
  export function microphoneState() {