pxt-common-packages 10.3.9 → 10.3.11

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 (37) hide show
  1. package/built/common-sim.js +0 -2
  2. package/libs/azureiot/built/debug/binary.js +461 -461
  3. package/libs/color/built/debug/binary.js +8 -8
  4. package/libs/color-sensor/built/debug/binary.js +8 -8
  5. package/libs/controller/built/debug/binary.js +8126 -7957
  6. package/libs/controller---none/built/debug/binary.js +8105 -7936
  7. package/libs/datalogger/built/debug/binary.js +63 -63
  8. package/libs/edge-connector/built/debug/binary.js +8 -8
  9. package/libs/esp32/built/debug/binary.js +462 -462
  10. package/libs/game/_locales/game-strings.json +1 -1
  11. package/libs/game/built/debug/binary.js +8018 -7849
  12. package/libs/game/controller.ts +5 -0
  13. package/libs/game/game.ts +35 -18
  14. package/libs/game/info.ts +2 -2
  15. package/libs/game/sim/multiplayer.ts +0 -2
  16. package/libs/lcd/built/debug/binary.js +8 -8
  17. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  18. package/libs/lora/built/debug/binary.js +8 -8
  19. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  20. package/libs/mixer/melody.ts +1 -1
  21. package/libs/mixer/soundEffect.ts +1 -0
  22. package/libs/mqtt/built/debug/binary.js +176 -176
  23. package/libs/multiplayer/player.ts +15 -0
  24. package/libs/net/built/debug/binary.js +176 -176
  25. package/libs/net-game/built/debug/binary.js +9825 -9656
  26. package/libs/palette/built/debug/binary.js +8017 -7848
  27. package/libs/pixel/built/debug/binary.js +8 -8
  28. package/libs/power/built/debug/binary.js +8 -8
  29. package/libs/proximity/built/debug/binary.js +8 -8
  30. package/libs/radio/built/debug/binary.js +8 -8
  31. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  32. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  33. package/libs/screen/built/debug/binary.js +50 -50
  34. package/libs/servo/built/debug/binary.js +8 -8
  35. package/libs/sprite-scaling/built/debug/binary.js +8017 -7848
  36. package/libs/storyboard/built/debug/binary.js +8017 -7848
  37. package/package.json +1 -1
@@ -169,6 +169,11 @@ namespace controller {
169
169
  this._moveSpriteInternal(sprite, vx, vy);
170
170
  }
171
171
 
172
+ stopControllingSprite(sprite: Sprite) {
173
+ if (!sprite) return;
174
+ this._controlledSprites = this._controlledSprites.filter(s => s.s.id !== sprite.id);
175
+ }
176
+
172
177
  // use this instead of movesprite internally to avoid adding the "multiplayer" part
173
178
  // to the compiled program
174
179
  _moveSpriteInternal(sprite: Sprite, vx: number = 100, vy: number = 100) {
package/libs/game/game.ts CHANGED
@@ -21,8 +21,10 @@ namespace game {
21
21
  scoringType: ScoringType;
22
22
  winEffect: effects.BackgroundEffect;
23
23
  loseEffect: effects.BackgroundEffect;
24
- loseSound: music.Melody;
25
- winSound: music.Melody;
24
+ loseSound: music.Playable;
25
+ winSound: music.Playable;
26
+ loseSoundLooping: boolean;
27
+ winSoundLooping: boolean;
26
28
  winMessage: string;
27
29
  winMessageMultiplayer: string;
28
30
  loseMessage: string;
@@ -39,8 +41,10 @@ namespace game {
39
41
  this.scoringType = ScoringType.HighScore;
40
42
  this.winEffect = effects.confetti;
41
43
  this.loseEffect = effects.melt;
42
- this.winSound = music.powerUp;
43
- this.loseSound = music.wawawawaa;
44
+ this.winSound = music.melodyPlayable(music.powerUp);
45
+ this.loseSound = music.melodyPlayable(music.wawawawaa);
46
+ this.winSoundLooping = false;
47
+ this.loseSoundLooping = false;
44
48
  this.winMessage = "YOU WIN!";
45
49
  this.winMessageMultiplayer = "${WINNER} WINS!";
46
50
  this.loseMessage = "GAME OVER";
@@ -50,13 +54,13 @@ namespace game {
50
54
  this.scoringTypeSetByUser = false;
51
55
  }
52
56
 
53
- setScoringType(type: ScoringType, explicit?: boolean) {
57
+ setScoringType(type: ScoringType, explicit: boolean) {
54
58
  if (!explicit && this.scoringTypeSetByUser) return;
55
59
  this.scoringType = type;
56
60
  if (explicit) this.scoringTypeSetByUser = true;
57
61
  }
58
62
 
59
- setEffect(win: boolean, effect: effects.BackgroundEffect, explicit?: boolean) {
63
+ setEffect(win: boolean, effect: effects.BackgroundEffect, explicit: boolean) {
60
64
  if (!explicit && this.effectSetByUser) return;
61
65
  if (win) this.winEffect = effect;
62
66
  else this.loseEffect = effect;
@@ -66,17 +70,25 @@ namespace game {
66
70
  return win ? this.winEffect : this.loseEffect;
67
71
  }
68
72
 
69
- setSound(win: boolean, sound: music.Melody, explicit?: boolean) {
73
+ setSound(win: boolean, sound: music.Playable, looping: boolean, explicit: boolean) {
70
74
  if (!explicit && this.soundSetByUser) return;
71
- if (win) this.winSound = sound;
72
- else this.loseSound = sound;
75
+ if (win) {
76
+ this.winSound = sound;
77
+ this.winSoundLooping = looping;
78
+ } else {
79
+ this.loseSound = sound;
80
+ this.loseSoundLooping = looping;
81
+ }
73
82
  if (explicit) this.soundSetByUser = true;
74
83
  }
75
84
  getSound(win: boolean) {
76
85
  return win ? this.winSound : this.loseSound;
77
86
  }
87
+ getSoundLooping(win: boolean) {
88
+ return win ? this.winSoundLooping : this.loseSoundLooping;
89
+ }
78
90
 
79
- setMessage(win: boolean, message: string, explicit?: boolean) {
91
+ setMessage(win: boolean, message: string, explicit: boolean) {
80
92
  if (!explicit && this.messageSetByUser) return;
81
93
  if (win) this.winMessage = message;
82
94
  else this.loseMessage = message;
@@ -222,7 +234,7 @@ namespace game {
222
234
  //% win.shadow=toggleWinLose
223
235
  //% win.defl=true
224
236
  //% group="Game Over"
225
- //% weight=80
237
+ //% weight=90
226
238
  //% blockGap=8
227
239
  //% help=game/set-game-over-effect
228
240
  export function setGameOverEffect(win: boolean, effect: effects.BackgroundEffect) {
@@ -237,18 +249,21 @@ namespace game {
237
249
  * @param effect
238
250
  */
239
251
  //% blockId=game_setgameoversound
240
- //% block="use sound $sound for $win"
252
+ //% block="use $sound looping $looping for $win"
253
+ //% sound.shadow=music_melody_playable
241
254
  //% sound.defl=music.powerUp
255
+ //% looping.shadow=toggleOnOff
256
+ //% looping.defl=false
242
257
  //% win.shadow=toggleWinLose
243
258
  //% win.defl=true
244
259
  //% group="Game Over"
245
260
  //% weight=80
246
261
  //% blockGap=8
247
262
  //% help=game/set-game-over-sound
248
- export function setGameOverSound(win: boolean, sound: music.Melody) {
263
+ export function setGameOverSound(win: boolean, sound: music.Playable, looping: boolean) {
249
264
  init();
250
265
  const goc = game.gameOverConfig();
251
- goc.setSound(win, sound, true);
266
+ goc.setSound(win, sound, looping, true);
252
267
  }
253
268
 
254
269
  /**
@@ -262,7 +277,7 @@ namespace game {
262
277
  //% win.shadow=toggleWinLose
263
278
  //% win.defl=true
264
279
  //% group="Game Over"
265
- //% weight=80
280
+ //% weight=70
266
281
  //% blockGap=8
267
282
  //% help=game/set-game-over-message
268
283
  export function setGameOverMessage(win: boolean, message: string) {
@@ -279,7 +294,7 @@ namespace game {
279
294
  //% block="use $type as best score"
280
295
  //% type.defl=ScoringType.HighScore
281
296
  //% group="Game Over"
282
- //% weight=80
297
+ //% weight=60
283
298
  //% blockGap=8
284
299
  //% help=game/set-game-over-scoring-type
285
300
  export function setGameOverScoringType(type: ScoringType) {
@@ -314,7 +329,7 @@ namespace game {
314
329
  //% blockId=gameOver2 block="game over $win"
315
330
  //% win.shadow=toggleWinLose
316
331
  //% win.defl=true
317
- //% weight=80
332
+ //% weight=100
318
333
  //% blockGap=8
319
334
  //% help=game/over
320
335
  //% group="Game Over"
@@ -352,6 +367,8 @@ namespace game {
352
367
  const message = goc.getMessage(win, preferMultiplayer);
353
368
  const effect = goc.getEffect(win);
354
369
  const sound = goc.getSound(win);
370
+ const looping = goc.getSoundLooping(win);
371
+ const playbackMode = looping ? music.PlaybackMode.LoopingInBackground : music.PlaybackMode.InBackground;
355
372
 
356
373
  // releasing memory and clear fibers. Do not add anything that releases the fiber until background is set below,
357
374
  // or screen will be cleared on the new frame and will not appear as background in the game over screen.
@@ -362,7 +379,7 @@ namespace game {
362
379
  pushScene();
363
380
  scene.setBackgroundImage(screen.clone());
364
381
 
365
- if (sound) sound.play();
382
+ if (sound) music.play(sound, playbackMode);
366
383
  if (effect) effect.startScreenEffect();
367
384
 
368
385
  pause(400);
package/libs/game/info.ts CHANGED
@@ -161,7 +161,7 @@ namespace info {
161
161
  // Clear effect and sound, unless set by user
162
162
  const goc = game.gameOverConfig();
163
163
  goc.setEffect(false, null, false);
164
- goc.setSound(false, null, false);
164
+ goc.setSound(false, null, false, false);
165
165
  game.gameOver(false);
166
166
  }
167
167
  }
@@ -779,7 +779,7 @@ namespace info {
779
779
  // Clear effect and sound, unless set by user
780
780
  const goc = game.gameOverConfig();
781
781
  goc.setEffect(false, null, false);
782
- goc.setSound(false, null, false);
782
+ goc.setSound(false, null, false, false);
783
783
  game.gameOver(false);
784
784
  }
785
785
  }
@@ -17,8 +17,6 @@ namespace pxsim.multiplayer {
17
17
  }
18
18
 
19
19
  export function postIcon(iconType: IconType, slot: number, im: pxsim.RefImage) {
20
- if (getMultiplayerState().origin !== "server")
21
- return;
22
20
  if (im._width * im._height > 64 * 64) {
23
21
  // setting 64x64 as max size for icon for now
24
22
  return;
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48685(s) {
59
+ function _main___P48703(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___48928 = (undefined);
70
- globals._pollEventQueue___48941 = (undefined);
69
+ globals._intervals___48946 = (undefined);
70
+ globals._pollEventQueue___48959 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48685.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48685.continuations = [ ]
75
+ _main___P48703.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48703.continuations = [ ]
77
77
 
78
- function _main___P48685_mk(s) {
78
+ function _main___P48703_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48685, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48703, 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___P48685_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48685
91
+ return _main___P48703
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___P98387(s) {
59
+ function _main___P98441(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___98630 = (undefined);
70
- globals._pollEventQueue___98643 = (undefined);
69
+ globals._intervals___98684 = (undefined);
70
+ globals._pollEventQueue___98697 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P98387.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P98387.continuations = [ ]
75
+ _main___P98441.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P98441.continuations = [ ]
77
77
 
78
- function _main___P98387_mk(s) {
78
+ function _main___P98441_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P98387, depth: s.depth + 1,
81
+ parent: s, fn: _main___P98441, 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___P98387_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P98387
91
+ return _main___P98441
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___P59987(s) {
59
+ function _main___P60005(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___60230 = (undefined);
70
- globals._pollEventQueue___60243 = (undefined);
69
+ globals._intervals___60248 = (undefined);
70
+ globals._pollEventQueue___60261 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P59987.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P59987.continuations = [ ]
75
+ _main___P60005.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P60005.continuations = [ ]
77
77
 
78
- function _main___P59987_mk(s) {
78
+ function _main___P60005_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P59987, depth: s.depth + 1,
81
+ parent: s, fn: _main___P60005, 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___P59987_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P59987
91
+ return _main___P60005
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___P191315(s) {
59
+ function _main___P191441(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___191558 = (undefined);
70
- globals._pollEventQueue___191571 = (undefined);
69
+ globals._intervals___191684 = (undefined);
70
+ globals._pollEventQueue___191697 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P191315.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P191315.continuations = [ ]
75
+ _main___P191441.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P191441.continuations = [ ]
77
77
 
78
- function _main___P191315_mk(s) {
78
+ function _main___P191441_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P191315, depth: s.depth + 1,
81
+ parent: s, fn: _main___P191441, 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___P191315_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P191315
91
+ return _main___P191441
92
92
  })
@@ -590,13 +590,13 @@ namespace music {
590
590
  }
591
591
  }
592
592
 
593
- //% shim=TD_ID
594
593
  //% blockId=music_song_field_editor
595
594
  //% block="song $song"
596
595
  //% song.fieldEditor=musiceditor
597
596
  //% toolboxParent=music_playable_play
598
597
  //% toolboxParentArgument=toPlay
599
598
  //% group="Songs"
599
+ //% duplicateShadowOnDrag
600
600
  export function createSong(song: Buffer): Playable {
601
601
  return new sequencer.Song(song);
602
602
  }
@@ -158,6 +158,7 @@ namespace music {
158
158
  //% toolboxParentArgument=toPlay
159
159
  //% weight=20
160
160
  //% group="Sounds"
161
+ //% duplicateShadowOnDrag
161
162
  export function createSoundEffect(waveShape: WaveShape, startFrequency: number, endFrequency: number, startVolume: number, endVolume: number, duration: number, effect: SoundExpressionEffect, interpolation: InterpolationCurve): SoundEffect {
162
163
  const result = new SoundEffect();
163
164