pxt-arcade 1.9.8 → 1.9.12

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 (57) hide show
  1. package/built/common-sim.js +63 -63
  2. package/built/sim.js +63 -91
  3. package/built/target.js +240 -141
  4. package/built/target.json +240 -141
  5. package/built/targetlight.json +5 -5
  6. package/docs/GameList.json +13 -9
  7. package/docs/domains.html +1 -0
  8. package/docs/hour-of-code-2020.html +2 -2
  9. package/docs/kiosk.html +1 -1
  10. package/docs/kprottsman.html +313 -0
  11. package/docs/projects/SUMMARY.md +1 -1
  12. package/docs/skillmap/educator-info/jungle-map-info.md +10 -10
  13. package/docs/skillmap/jungle/jungle1.md +1 -1
  14. package/docs/skillmap/jungle.md +6 -6
  15. package/docs/skillmaps.md +2 -2
  16. package/docs/static/kiosk/asset-manifest.json +8 -6
  17. package/docs/static/kiosk/static/css/main.7ce3be17.css +2 -0
  18. package/docs/static/kiosk/static/css/main.7ce3be17.css.map +1 -0
  19. package/docs/static/kiosk/static/js/main.e73a8a65.js +3 -0
  20. package/docs/static/kiosk/static/js/{main.9d5caf82.js.LICENSE.txt → main.e73a8a65.js.LICENSE.txt} +33 -0
  21. package/docs/static/kiosk/static/js/main.e73a8a65.js.map +1 -0
  22. package/docs/static/kiosk/static/media/PressStart2P-Regular.21503c6a5385ab41dde9.ttf +0 -0
  23. package/docs/static/kiosk/static/media/Share-Regular.380ba4337f16f81374cd.ttf +0 -0
  24. package/docs/static/pages/kprottsman/apple.png +0 -0
  25. package/docs/static/pages/kprottsman/arcade.png +0 -0
  26. package/docs/static/pages/kprottsman/balloon.png +0 -0
  27. package/docs/static/pages/kprottsman/card.png +0 -0
  28. package/docs/static/pages/kprottsman/chase-the-pizza.png +0 -0
  29. package/docs/static/pages/kprottsman/clovers.png +0 -0
  30. package/docs/static/pages/kprottsman/design.png +0 -0
  31. package/docs/static/pages/kprottsman/galga.png +0 -0
  32. package/docs/static/pages/kprottsman/hamlet.png +0 -0
  33. package/docs/static/pages/kprottsman/home.png +0 -0
  34. package/docs/static/pages/kprottsman/lemon-leak.png +0 -0
  35. package/docs/static/pages/kprottsman/memory.png +0 -0
  36. package/docs/static/pages/kprottsman/micro-bit.png +0 -0
  37. package/docs/static/pages/kprottsman/minecraft.png +0 -0
  38. package/docs/static/pages/kprottsman/monster-racer.png +0 -0
  39. package/docs/static/pages/kprottsman/nfl.png +0 -0
  40. package/docs/static/pages/kprottsman/ocean-jam.png +0 -0
  41. package/docs/static/pages/kprottsman/pixel-background-primary.png +0 -0
  42. package/docs/static/pages/kprottsman/pixel-background-secondary.png +0 -0
  43. package/docs/static/pages/kprottsman/shadowed-aside-frame.png +0 -0
  44. package/docs/static/pages/kprottsman/shadowed-button-frame.png +0 -0
  45. package/docs/static/pages/kprottsman/shadowed-primary-frame.png +0 -0
  46. package/docs/static/pages/kprottsman/shark-attack.png +0 -0
  47. package/docs/static/pages/kprottsman/simulator.png +0 -0
  48. package/docs/static/pages/kprottsman/styles.css +541 -0
  49. package/docs/static/pages/kprottsman/timeflies.png +0 -0
  50. package/package.json +4 -4
  51. package/targetconfig.json +4 -2
  52. package/docs/static/kiosk/GameList.json +0 -35
  53. package/docs/static/kiosk/index.html +0 -1
  54. package/docs/static/kiosk/static/css/main.dadee71f.css +0 -2
  55. package/docs/static/kiosk/static/css/main.dadee71f.css.map +0 -1
  56. package/docs/static/kiosk/static/js/main.9d5caf82.js +0 -3
  57. package/docs/static/kiosk/static/js/main.9d5caf82.js.map +0 -1
@@ -5,11 +5,11 @@ var pxsim;
5
5
  function onGesture(gesture, handler) {
6
6
  let b = pxsim.accelerometer();
7
7
  b.accelerometer.activate();
8
- if (gesture == 11 /* ACCELEROMETER_EVT_SHAKE */ && !b.useShake) {
8
+ if (gesture == 11 /* DAL.ACCELEROMETER_EVT_SHAKE */ && !b.useShake) {
9
9
  b.useShake = true;
10
10
  pxsim.runtime.queueDisplayUpdate();
11
11
  }
12
- pxsim.pxtcore.registerWithDal(13 /* DEVICE_ID_GESTURE */, gesture, handler);
12
+ pxsim.pxtcore.registerWithDal(13 /* DAL.DEVICE_ID_GESTURE */, gesture, handler);
13
13
  }
14
14
  input.onGesture = onGesture;
15
15
  function rotation(kind) {
@@ -99,7 +99,7 @@ var pxsim;
99
99
  this.shake = { x: false, y: false, z: false, count: 0, shaken: 0, timer: 0 }; // State information needed to detect shake events.
100
100
  this.isActive = false;
101
101
  this.sampleRange = 2;
102
- this.id = 5 /* DEVICE_ID_ACCELEROMETER */;
102
+ this.id = 5 /* DAL.DEVICE_ID_ACCELEROMETER */;
103
103
  }
104
104
  setSampleRange(range) {
105
105
  this.activate();
@@ -123,7 +123,7 @@ var pxsim;
123
123
  // Update gesture tracking
124
124
  this.updateGesture();
125
125
  // Indicate that a new sample is available
126
- pxsim.board().bus.queue(this.id, 1 /* ACCELEROMETER_EVT_DATA_UPDATE */);
126
+ pxsim.board().bus.queue(this.id, 1 /* DAL.ACCELEROMETER_EVT_DATA_UPDATE */);
127
127
  }
128
128
  instantaneousAccelerationSquared() {
129
129
  // Use pythagoras theorem to determine the combined force acting on the device.
@@ -144,21 +144,21 @@ var pxsim;
144
144
  //
145
145
  // If we see enough zero crossings in succession (MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD), then we decide that the device
146
146
  // has been shaken.
147
- if ((this.getX() < -400 /* ACCELEROMETER_SHAKE_TOLERANCE */ && this.shake.x) || (this.getX() > 400 /* ACCELEROMETER_SHAKE_TOLERANCE */ && !this.shake.x)) {
147
+ if ((this.getX() < -400 /* DAL.ACCELEROMETER_SHAKE_TOLERANCE */ && this.shake.x) || (this.getX() > 400 /* DAL.ACCELEROMETER_SHAKE_TOLERANCE */ && !this.shake.x)) {
148
148
  shakeDetected = true;
149
149
  this.shake.x = !this.shake.x;
150
150
  }
151
- if ((this.getY() < -400 /* ACCELEROMETER_SHAKE_TOLERANCE */ && this.shake.y) || (this.getY() > 400 /* ACCELEROMETER_SHAKE_TOLERANCE */ && !this.shake.y)) {
151
+ if ((this.getY() < -400 /* DAL.ACCELEROMETER_SHAKE_TOLERANCE */ && this.shake.y) || (this.getY() > 400 /* DAL.ACCELEROMETER_SHAKE_TOLERANCE */ && !this.shake.y)) {
152
152
  shakeDetected = true;
153
153
  this.shake.y = !this.shake.y;
154
154
  }
155
- if ((this.getZ() < -400 /* ACCELEROMETER_SHAKE_TOLERANCE */ && this.shake.z) || (this.getZ() > 400 /* ACCELEROMETER_SHAKE_TOLERANCE */ && !this.shake.z)) {
155
+ if ((this.getZ() < -400 /* DAL.ACCELEROMETER_SHAKE_TOLERANCE */ && this.shake.z) || (this.getZ() > 400 /* DAL.ACCELEROMETER_SHAKE_TOLERANCE */ && !this.shake.z)) {
156
156
  shakeDetected = true;
157
157
  this.shake.z = !this.shake.z;
158
158
  }
159
- if (shakeDetected && this.shake.count < 4 /* ACCELEROMETER_SHAKE_COUNT_THRESHOLD */ && ++this.shake.count == 4 /* ACCELEROMETER_SHAKE_COUNT_THRESHOLD */)
159
+ if (shakeDetected && this.shake.count < 4 /* DAL.ACCELEROMETER_SHAKE_COUNT_THRESHOLD */ && ++this.shake.count == 4 /* DAL.ACCELEROMETER_SHAKE_COUNT_THRESHOLD */)
160
160
  this.shake.shaken = 1;
161
- if (++this.shake.timer >= 10 /* ACCELEROMETER_SHAKE_DAMPING */) {
161
+ if (++this.shake.timer >= 10 /* DAL.ACCELEROMETER_SHAKE_DAMPING */) {
162
162
  this.shake.timer = 0;
163
163
  if (this.shake.count > 0) {
164
164
  if (--this.shake.count == 0)
@@ -166,29 +166,29 @@ var pxsim;
166
166
  }
167
167
  }
168
168
  if (this.shake.shaken)
169
- return 11 /* ACCELEROMETER_EVT_SHAKE */;
169
+ return 11 /* DAL.ACCELEROMETER_EVT_SHAKE */;
170
170
  let sq = (n) => n * n;
171
- if (force < sq(400 /* ACCELEROMETER_FREEFALL_TOLERANCE */))
172
- return 7 /* ACCELEROMETER_EVT_FREEFALL */;
173
- if (force > sq(3072 /* ACCELEROMETER_3G_TOLERANCE */))
174
- return 8 /* ACCELEROMETER_EVT_3G */;
175
- if (force > sq(6144 /* ACCELEROMETER_6G_TOLERANCE */))
176
- return 9 /* ACCELEROMETER_EVT_6G */;
177
- if (force > sq(8192 /* ACCELEROMETER_8G_TOLERANCE */))
178
- return 10 /* ACCELEROMETER_EVT_8G */;
171
+ if (force < sq(400 /* DAL.ACCELEROMETER_FREEFALL_TOLERANCE */))
172
+ return 7 /* DAL.ACCELEROMETER_EVT_FREEFALL */;
173
+ if (force > sq(3072 /* DAL.ACCELEROMETER_3G_TOLERANCE */))
174
+ return 8 /* DAL.ACCELEROMETER_EVT_3G */;
175
+ if (force > sq(6144 /* DAL.ACCELEROMETER_6G_TOLERANCE */))
176
+ return 9 /* DAL.ACCELEROMETER_EVT_6G */;
177
+ if (force > sq(8192 /* DAL.ACCELEROMETER_8G_TOLERANCE */))
178
+ return 10 /* DAL.ACCELEROMETER_EVT_8G */;
179
179
  // Determine our posture.
180
- if (this.getX() < (-1000 + 200 /* ACCELEROMETER_TILT_TOLERANCE */))
181
- return 3 /* ACCELEROMETER_EVT_TILT_LEFT */;
182
- if (this.getX() > (1000 - 200 /* ACCELEROMETER_TILT_TOLERANCE */))
183
- return 4 /* ACCELEROMETER_EVT_TILT_RIGHT */;
184
- if (this.getY() < (-1000 + 200 /* ACCELEROMETER_TILT_TOLERANCE */))
185
- return 1 /* ACCELEROMETER_EVT_TILT_UP */;
186
- if (this.getY() > (1000 - 200 /* ACCELEROMETER_TILT_TOLERANCE */))
187
- return 2 /* ACCELEROMETER_EVT_TILT_DOWN */;
188
- if (this.getZ() < (-1000 + 200 /* ACCELEROMETER_TILT_TOLERANCE */))
189
- return 5 /* ACCELEROMETER_EVT_FACE_UP */;
190
- if (this.getZ() > (1000 - 200 /* ACCELEROMETER_TILT_TOLERANCE */))
191
- return 6 /* ACCELEROMETER_EVT_FACE_DOWN */;
180
+ if (this.getX() < (-1000 + 200 /* DAL.ACCELEROMETER_TILT_TOLERANCE */))
181
+ return 3 /* DAL.ACCELEROMETER_EVT_TILT_LEFT */;
182
+ if (this.getX() > (1000 - 200 /* DAL.ACCELEROMETER_TILT_TOLERANCE */))
183
+ return 4 /* DAL.ACCELEROMETER_EVT_TILT_RIGHT */;
184
+ if (this.getY() < (-1000 + 200 /* DAL.ACCELEROMETER_TILT_TOLERANCE */))
185
+ return 1 /* DAL.ACCELEROMETER_EVT_TILT_UP */;
186
+ if (this.getY() > (1000 - 200 /* DAL.ACCELEROMETER_TILT_TOLERANCE */))
187
+ return 2 /* DAL.ACCELEROMETER_EVT_TILT_DOWN */;
188
+ if (this.getZ() < (-1000 + 200 /* DAL.ACCELEROMETER_TILT_TOLERANCE */))
189
+ return 5 /* DAL.ACCELEROMETER_EVT_FACE_UP */;
190
+ if (this.getZ() > (1000 - 200 /* DAL.ACCELEROMETER_TILT_TOLERANCE */))
191
+ return 6 /* DAL.ACCELEROMETER_EVT_FACE_DOWN */;
192
192
  return 0;
193
193
  }
194
194
  updateGesture() {
@@ -196,7 +196,7 @@ var pxsim;
196
196
  let g = this.instantaneousPosture();
197
197
  // Perform some low pass filtering to reduce jitter from any detected effects
198
198
  if (g == this.currentGesture) {
199
- if (this.sigma < 5 /* ACCELEROMETER_GESTURE_DAMPING */)
199
+ if (this.sigma < 5 /* DAL.ACCELEROMETER_GESTURE_DAMPING */)
200
200
  this.sigma++;
201
201
  }
202
202
  else {
@@ -204,9 +204,9 @@ var pxsim;
204
204
  this.sigma = 0;
205
205
  }
206
206
  // If we've reached threshold, update our record and raise the relevant event...
207
- if (this.currentGesture != this.lastGesture && this.sigma >= 5 /* ACCELEROMETER_GESTURE_DAMPING */) {
207
+ if (this.currentGesture != this.lastGesture && this.sigma >= 5 /* DAL.ACCELEROMETER_GESTURE_DAMPING */) {
208
208
  this.lastGesture = this.currentGesture;
209
- pxsim.board().bus.queue(13 /* DEVICE_ID_GESTURE */, this.lastGesture);
209
+ pxsim.board().bus.queue(13 /* DAL.DEVICE_ID_GESTURE */, this.lastGesture);
210
210
  }
211
211
  }
212
212
  /**
@@ -728,21 +728,21 @@ var pxsim;
728
728
  this.pressed = p;
729
729
  if (p) {
730
730
  this._wasPressed = true;
731
- pxsim.board().bus.queue(this.id, 1 /* DEVICE_BUTTON_EVT_DOWN */);
731
+ pxsim.board().bus.queue(this.id, 1 /* DAL.DEVICE_BUTTON_EVT_DOWN */);
732
732
  this._pressedTime = pxsim.runtime.runningTime();
733
733
  }
734
734
  else if (this._pressedTime !== -1) {
735
- pxsim.board().bus.queue(this.id, 2 /* DEVICE_BUTTON_EVT_UP */);
735
+ pxsim.board().bus.queue(this.id, 2 /* DAL.DEVICE_BUTTON_EVT_UP */);
736
736
  const current = pxsim.runtime.runningTime();
737
- if (current - this._pressedTime >= 1000 /* DEVICE_BUTTON_LONG_CLICK_TIME */) {
738
- pxsim.board().bus.queue(this.id, 4 /* DEVICE_BUTTON_EVT_LONG_CLICK */);
737
+ if (current - this._pressedTime >= 1000 /* DAL.DEVICE_BUTTON_LONG_CLICK_TIME */) {
738
+ pxsim.board().bus.queue(this.id, 4 /* DAL.DEVICE_BUTTON_EVT_LONG_CLICK */);
739
739
  }
740
740
  else {
741
- pxsim.board().bus.queue(this.id, 3 /* DEVICE_BUTTON_EVT_CLICK */);
741
+ pxsim.board().bus.queue(this.id, 3 /* DAL.DEVICE_BUTTON_EVT_CLICK */);
742
742
  }
743
743
  if (this._clickedTime !== -1) {
744
744
  if (current - this._clickedTime <= DOUBLE_CLICK_TIME) {
745
- pxsim.board().bus.queue(this.id, 6 /* DEVICE_BUTTON_EVT_DOUBLE_CLICK */);
745
+ pxsim.board().bus.queue(this.id, 6 /* DAL.DEVICE_BUTTON_EVT_DOUBLE_CLICK */);
746
746
  }
747
747
  }
748
748
  this._clickedTime = current;
@@ -767,9 +767,9 @@ var pxsim;
767
767
  this.usesButtonAB = false;
768
768
  this.buttonsByPin = {};
769
769
  this.buttons = buttons || [
770
- new CommonButton(1 /* DEVICE_ID_BUTTON_A */),
771
- new CommonButton(2 /* DEVICE_ID_BUTTON_B */),
772
- new CommonButton(3 /* DEVICE_ID_BUTTON_AB */)
770
+ new CommonButton(1 /* DAL.DEVICE_ID_BUTTON_A */),
771
+ new CommonButton(2 /* DAL.DEVICE_ID_BUTTON_B */),
772
+ new CommonButton(3 /* DAL.DEVICE_ID_BUTTON_AB */)
773
773
  ];
774
774
  this.buttons.forEach(btn => this.buttonsByPin[btn.id] = btn);
775
775
  }
@@ -966,10 +966,10 @@ var pxsim;
966
966
  this.state = state;
967
967
  switch (state) {
968
968
  case ThresholdState.High:
969
- pxsim.board().bus.queue(this.id, 2 /* SENSOR_THRESHOLD_HIGH */);
969
+ pxsim.board().bus.queue(this.id, 2 /* DAL.SENSOR_THRESHOLD_HIGH */);
970
970
  break;
971
971
  case ThresholdState.Low:
972
- pxsim.board().bus.queue(this.id, 1 /* SENSOR_THRESHOLD_LOW */);
972
+ pxsim.board().bus.queue(this.id, 1 /* DAL.SENSOR_THRESHOLD_LOW */);
973
973
  break;
974
974
  case ThresholdState.Normal:
975
975
  break;
@@ -1189,8 +1189,8 @@ var pxsim;
1189
1189
  const old = this.value;
1190
1190
  this.value = value;
1191
1191
  const b = pxsim.board();
1192
- if (b && this.eventMode == 2 /* DEVICE_PIN_EVENT_ON_EDGE */ && old != this.value)
1193
- b.bus.queue(this.id, this.value > 0 ? 2 /* DEVICE_PIN_EVT_RISE */ : 3 /* DEVICE_PIN_EVT_FALL */);
1192
+ if (b && this.eventMode == 2 /* DAL.DEVICE_PIN_EVENT_ON_EDGE */ && old != this.value)
1193
+ b.bus.queue(this.id, this.value > 0 ? 2 /* DAL.DEVICE_PIN_EVT_RISE */ : 3 /* DAL.DEVICE_PIN_EVT_FALL */);
1194
1194
  }
1195
1195
  digitalReadPin() {
1196
1196
  this.mode = PinFlags.Digital | PinFlags.Input;
@@ -1251,13 +1251,13 @@ var pxsim;
1251
1251
  onEvent(ev, handler) {
1252
1252
  const b = pxsim.board();
1253
1253
  switch (ev) {
1254
- case 4 /* DEVICE_PIN_EVT_PULSE_HI */:
1255
- case 5 /* DEVICE_PIN_EVT_PULSE_LO */:
1256
- this.eventMode = 3 /* DEVICE_PIN_EVENT_ON_PULSE */;
1254
+ case 4 /* DAL.DEVICE_PIN_EVT_PULSE_HI */:
1255
+ case 5 /* DAL.DEVICE_PIN_EVT_PULSE_LO */:
1256
+ this.eventMode = 3 /* DAL.DEVICE_PIN_EVENT_ON_PULSE */;
1257
1257
  break;
1258
- case 2 /* DEVICE_PIN_EVT_RISE */:
1259
- case 3 /* DEVICE_PIN_EVT_FALL */:
1260
- this.eventMode = 2 /* DEVICE_PIN_EVENT_ON_EDGE */;
1258
+ case 2 /* DAL.DEVICE_PIN_EVT_RISE */:
1259
+ case 3 /* DAL.DEVICE_PIN_EVT_FALL */:
1260
+ this.eventMode = 2 /* DAL.DEVICE_PIN_EVENT_ON_EDGE */;
1261
1261
  break;
1262
1262
  default:
1263
1263
  return;
@@ -2056,7 +2056,7 @@ var pxsim;
2056
2056
  */
2057
2057
  function onPulsed(name, high, body) {
2058
2058
  pxsim.pins.markUsed(name);
2059
- onEvent(name, high ? 4 /* DEVICE_PIN_EVT_PULSE_HI */ : 5 /* DEVICE_PIN_EVT_PULSE_LO */, body);
2059
+ onEvent(name, high ? 4 /* DAL.DEVICE_PIN_EVT_PULSE_HI */ : 5 /* DAL.DEVICE_PIN_EVT_PULSE_LO */, body);
2060
2060
  }
2061
2061
  DigitalInOutPinMethods.onPulsed = onPulsed;
2062
2062
  function onEvent(name, ev, body) {
@@ -2071,7 +2071,7 @@ var pxsim;
2071
2071
  */
2072
2072
  function pulseIn(name, high, maxDuration = 2000000) {
2073
2073
  pxsim.pins.markUsed(name);
2074
- const pulse = high ? 4 /* DEVICE_PIN_EVT_PULSE_HI */ : 5 /* DEVICE_PIN_EVT_PULSE_LO */;
2074
+ const pulse = high ? 4 /* DAL.DEVICE_PIN_EVT_PULSE_HI */ : 5 /* DAL.DEVICE_PIN_EVT_PULSE_LO */;
2075
2075
  // Always return default value, can't simulate
2076
2076
  return 500;
2077
2077
  }
@@ -3066,10 +3066,10 @@ var pxsim;
3066
3066
  let b = pxsim.lightSensorState();
3067
3067
  b.setUsed();
3068
3068
  switch (condition) {
3069
- case 1 /* SENSOR_THRESHOLD_LOW */:
3069
+ case 1 /* DAL.SENSOR_THRESHOLD_LOW */:
3070
3070
  b.setLowThreshold(value);
3071
3071
  break;
3072
- case 2 /* SENSOR_THRESHOLD_HIGH */:
3072
+ case 2 /* DAL.SENSOR_THRESHOLD_HIGH */:
3073
3073
  b.setHighThreshold(value);
3074
3074
  break;
3075
3075
  }
@@ -3101,7 +3101,7 @@ var pxsim;
3101
3101
  if (!b)
3102
3102
  return;
3103
3103
  b.setUsed();
3104
- pxsim.pxtcore.registerWithDal(b.id, 2 /* LEVEL_THRESHOLD_HIGH */, body);
3104
+ pxsim.pxtcore.registerWithDal(b.id, 2 /* DAL.LEVEL_THRESHOLD_HIGH */, body);
3105
3105
  }
3106
3106
  input.onLoudSound = onLoudSound;
3107
3107
  function setLoudSoundThreshold(value) {
@@ -4457,7 +4457,7 @@ var pxsim;
4457
4457
  const rd = new Uint32Array(ca.buffer);
4458
4458
  const src = buf.data;
4459
4459
  if (48 != src.length)
4460
- pxsim.pxtrt.panic(911 /* PANIC_SCREEN_ERROR */);
4460
+ pxsim.pxtrt.panic(911 /* pxsim.PXT_PANIC.PANIC_SCREEN_ERROR */);
4461
4461
  this.palette = new Uint32Array((src.length / 3) | 0);
4462
4462
  for (let i = 0; i < this.palette.length; ++i) {
4463
4463
  const p = i * 3;
@@ -4810,10 +4810,10 @@ var pxsim;
4810
4810
  return;
4811
4811
  }
4812
4812
  else if (left) {
4813
- pxsim.board().bus.queue(SlideSwitchState.id, 2 /* DEVICE_BUTTON_EVT_UP */);
4813
+ pxsim.board().bus.queue(SlideSwitchState.id, 2 /* DAL.DEVICE_BUTTON_EVT_UP */);
4814
4814
  }
4815
4815
  else {
4816
- pxsim.board().bus.queue(SlideSwitchState.id, 1 /* DEVICE_BUTTON_EVT_DOWN */);
4816
+ pxsim.board().bus.queue(SlideSwitchState.id, 1 /* DAL.DEVICE_BUTTON_EVT_DOWN */);
4817
4817
  }
4818
4818
  this.left = left;
4819
4819
  }
@@ -4951,7 +4951,7 @@ var pxsim;
4951
4951
  const t = unit == pxsim.TemperatureUnit.Celsius
4952
4952
  ? temperature
4953
4953
  : (((temperature - 32) * 10) / 18 >> 0);
4954
- if (condition === 2 /* LEVEL_THRESHOLD_HIGH */) {
4954
+ if (condition === 2 /* DAL.LEVEL_THRESHOLD_HIGH */) {
4955
4955
  b.setHighThreshold(t);
4956
4956
  }
4957
4957
  else {
@@ -5310,7 +5310,7 @@ var pxsim;
5310
5310
  }
5311
5311
  _wifi.eventID = eventID;
5312
5312
  function scanStart() {
5313
- _raiseEvent(1 /* ScanDone */);
5313
+ _raiseEvent(1 /* WifiEvent.ScanDone */);
5314
5314
  }
5315
5315
  _wifi.scanStart = scanStart;
5316
5316
  function startLoginServer() {
@@ -5325,7 +5325,7 @@ var pxsim;
5325
5325
  }
5326
5326
  _wifi.scanResults = scanResults;
5327
5327
  function connect(ssid, pass) {
5328
- _raiseEvent(2 /* GotIP */);
5328
+ _raiseEvent(2 /* WifiEvent.GotIP */);
5329
5329
  return 0;
5330
5330
  }
5331
5331
  _wifi.connect = connect;
package/built/sim.js CHANGED
@@ -1,8 +1,10 @@
1
1
  var pxsim;
2
2
  (function (pxsim) {
3
+ // Keep in sync with pxt-common-packages/libs/game/keymap.ts
3
4
  let Key;
4
5
  (function (Key) {
5
6
  Key[Key["None"] = 0] = "None";
7
+ // Player 1
6
8
  Key[Key["Left"] = 1] = "Left";
7
9
  Key[Key["Up"] = 2] = "Up";
8
10
  Key[Key["Right"] = 3] = "Right";
@@ -10,58 +12,22 @@ var pxsim;
10
12
  Key[Key["A"] = 5] = "A";
11
13
  Key[Key["B"] = 6] = "B";
12
14
  Key[Key["Menu"] = 7] = "Menu";
13
- // Player 2 keys here too
15
+ // Player 2 = Player 1 + 7
16
+ // Player 3 = Player 2 + 7
17
+ // Player 4 = Player 3 + 7
14
18
  // system keys
15
19
  Key[Key["Screenshot"] = -1] = "Screenshot";
16
20
  Key[Key["Gif"] = -2] = "Gif";
17
21
  Key[Key["Reset"] = -3] = "Reset";
18
22
  Key[Key["TogglePause"] = -4] = "TogglePause";
19
23
  })(Key = pxsim.Key || (pxsim.Key = {}));
20
- function mapKey(which) {
21
- switch (which) {
22
- case 65: // A
23
- case 37: // Left arrow
24
- return Key.Left;
25
- case 87: // W
26
- case 38: // Up arrow
27
- return Key.Up;
28
- case 68: // D
29
- case 39: // right arrow
30
- return Key.Right;
31
- case 83: // S
32
- case 40: // down arrow
33
- return Key.Down;
34
- case 32: // Space
35
- case 81: // Q
36
- case 90: // Z
37
- return Key.A;
38
- case 13: // Enter
39
- case 88: // X
40
- case 69: // E
41
- return Key.B;
42
- // Player two (see the local-multiplayer package)
43
- case 74: // J
44
- return Key.Left + 7;
45
- case 73: // I
46
- return Key.Up + 7;
47
- case 76: // L
48
- return Key.Right + 7;
49
- case 75: // K
50
- return Key.Down + 7;
51
- case 85: // U
52
- return Key.A + 7;
53
- case 79: // O
54
- return Key.B + 7;
55
- // system keys
56
- // screenshot
57
- case 80: // P
58
- return Key.Screenshot;
59
- case 82: // R
60
- return Key.Gif;
61
- default: return Key.None;
62
- }
63
- }
64
- pxsim.mapKey = mapKey;
24
+ // Map of MouseEvent.button to keymap.KeyCode
25
+ // Values are from the `KeyCode` enum in pxt-common-packages/libs/game/keymap.ts
26
+ pxsim.MouseButtonToKeyCode = {
27
+ 0: -1,
28
+ 1: -3,
29
+ 2: -2, // Right button
30
+ };
65
31
  function pauseAsync(ms) {
66
32
  return pxsim.U.delay(ms);
67
33
  }
@@ -230,6 +196,24 @@ var pxsim;
230
196
  if (!document.hasFocus())
231
197
  window.focus();
232
198
  };
199
+ window.onmousedown = function (e) {
200
+ const b = board();
201
+ if (b) {
202
+ const keyCode = pxsim.MouseButtonToKeyCode[e.button];
203
+ if (keyCode) {
204
+ b.setKey(keyCode, true, e);
205
+ }
206
+ }
207
+ };
208
+ window.onmouseup = function (e) {
209
+ const b = board();
210
+ if (b) {
211
+ const keyCode = pxsim.MouseButtonToKeyCode[e.button];
212
+ if (keyCode) {
213
+ b.setKey(keyCode, false, e);
214
+ }
215
+ }
216
+ };
233
217
  window.addEventListener("message", ev => {
234
218
  if (ev.data.button !== undefined) {
235
219
  let key;
@@ -339,6 +323,7 @@ var pxsim;
339
323
  RADIO_EVT_DATAGRAM: DAL.DEVICE_RADIO_EVT_DATAGRAM
340
324
  });
341
325
  this.multiplayerState = new pxsim.MultiplayerState();
326
+ this.keymapState = new pxsim.KeymapState();
342
327
  const scale = (isEdge() || isIE()) ? 10 : 1;
343
328
  this.gameplayer = new pxsim.visuals.GamePlayer(scale);
344
329
  throttleAnimation(cb => this.screenState.onChange = cb, () => this.gameplayer.draw(this.screenState));
@@ -347,7 +332,7 @@ var pxsim;
347
332
  return undefined;
348
333
  }
349
334
  setKey(which, isPressed, e) {
350
- let k = pxsim.mapKey(which);
335
+ let k = this.keymapState.getKey(which);
351
336
  if (k) {
352
337
  this.setButton(k, isPressed);
353
338
  e.preventDefault();
@@ -540,10 +525,10 @@ var pxsim;
540
525
  }
541
526
  buttonChanged(button, isPressed) {
542
527
  switch (button) {
543
- case visuals.SimulatorButton.A:
528
+ case pxsim.Key.A:
544
529
  this.setButtonState(button, isPressed, true);
545
530
  break;
546
- case visuals.SimulatorButton.B:
531
+ case pxsim.Key.B:
547
532
  this.setButtonState(button, isPressed, true);
548
533
  break;
549
534
  default:
@@ -570,16 +555,16 @@ var pxsim;
570
555
  const dy = ((y - bounds.top) * (SVG_WIDTH / bounds.height));
571
556
  const aDistance = Math.sqrt(Math.pow(dx - 30, 2) + Math.pow(dy - 15, 2));
572
557
  const bDistance = Math.sqrt(Math.pow(dx - 15, 2) + Math.pow(dy - 28, 2));
573
- this.setButtonState(visuals.SimulatorButton.A, aDistance < 8);
574
- this.setButtonState(visuals.SimulatorButton.B, bDistance < 8);
558
+ this.setButtonState(pxsim.Key.A, aDistance < 8);
559
+ this.setButtonState(pxsim.Key.B, bDistance < 8);
575
560
  pxsim.indicateFocus(true);
576
561
  }
577
562
  clearButtonPresses() {
578
- this.setButtonState(visuals.SimulatorButton.A, false);
579
- this.setButtonState(visuals.SimulatorButton.B, false);
563
+ this.setButtonState(pxsim.Key.A, false);
564
+ this.setButtonState(pxsim.Key.B, false);
580
565
  }
581
566
  setButtonState(button, pressed, quiet = false) {
582
- const isAButton = button === visuals.SimulatorButton.A;
567
+ const isAButton = button === pxsim.Key.A;
583
568
  const circle = isAButton ? this.aButton : this.bButton;
584
569
  const label = isAButton ? this.aLabel : this.bLabel;
585
570
  if (circle && label) {
@@ -589,9 +574,9 @@ var pxsim;
589
574
  }
590
575
  if (!quiet) {
591
576
  if (pressed) {
592
- if (!this.buttonPressCount[visuals.SimulatorButton[button]])
593
- this.buttonPressCount[visuals.SimulatorButton[button]] = 0;
594
- this.buttonPressCount[visuals.SimulatorButton[button]] += 1;
577
+ if (!this.buttonPressCount[pxsim.Key[button]])
578
+ this.buttonPressCount[pxsim.Key[button]] = 0;
579
+ this.buttonPressCount[pxsim.Key[button]] += 1;
595
580
  visuals.pressButton(button);
596
581
  }
597
582
  else
@@ -721,15 +706,15 @@ var pxsim;
721
706
  this.reset = document.getElementsByClassName("game-reset-button")[0];
722
707
  if (this.menu) {
723
708
  this.menu.onclick = () => {
724
- visuals.pressButton(visuals.SimulatorButton.Menu);
725
- visuals.releaseButton(visuals.SimulatorButton.Menu);
709
+ visuals.pressButton(pxsim.Key.Menu);
710
+ visuals.releaseButton(pxsim.Key.Menu);
726
711
  pxsim.indicateFocus(true);
727
712
  };
728
713
  }
729
714
  if (this.reset) {
730
715
  this.reset.onclick = () => {
731
- visuals.pressButton(visuals.SimulatorButton.Reset);
732
- visuals.releaseButton(visuals.SimulatorButton.Reset);
716
+ visuals.pressButton(pxsim.Key.Reset);
717
+ visuals.releaseButton(pxsim.Key.Reset);
733
718
  };
734
719
  }
735
720
  }
@@ -860,16 +845,16 @@ var pxsim;
860
845
  }
861
846
  buttonChanged(button, isPressed) {
862
847
  switch (button) {
863
- case visuals.SimulatorButton.Down:
848
+ case pxsim.Key.Down:
864
849
  this.updateDirection(this.dPadDown, isPressed);
865
850
  break;
866
- case visuals.SimulatorButton.Up:
851
+ case pxsim.Key.Up:
867
852
  this.updateDirection(this.dPadUp, isPressed);
868
853
  break;
869
- case visuals.SimulatorButton.Left:
854
+ case pxsim.Key.Left:
870
855
  this.updateDirection(this.dPadLeft, isPressed);
871
856
  break;
872
- case visuals.SimulatorButton.Right:
857
+ case pxsim.Key.Right:
873
858
  this.updateDirection(this.dPadRight, isPressed);
874
859
  break;
875
860
  default:
@@ -1076,21 +1061,21 @@ var pxsim;
1076
1061
  break;
1077
1062
  }
1078
1063
  if (down)
1079
- visuals.pressButton(visuals.SimulatorButton.Down);
1064
+ visuals.pressButton(pxsim.Key.Down);
1080
1065
  else
1081
- visuals.releaseButton(visuals.SimulatorButton.Down);
1066
+ visuals.releaseButton(pxsim.Key.Down);
1082
1067
  if (up)
1083
- visuals.pressButton(visuals.SimulatorButton.Up);
1068
+ visuals.pressButton(pxsim.Key.Up);
1084
1069
  else
1085
- visuals.releaseButton(visuals.SimulatorButton.Up);
1070
+ visuals.releaseButton(pxsim.Key.Up);
1086
1071
  if (left)
1087
- visuals.pressButton(visuals.SimulatorButton.Left);
1072
+ visuals.pressButton(pxsim.Key.Left);
1088
1073
  else
1089
- visuals.releaseButton(visuals.SimulatorButton.Left);
1074
+ visuals.releaseButton(pxsim.Key.Left);
1090
1075
  if (right)
1091
- visuals.pressButton(visuals.SimulatorButton.Right);
1076
+ visuals.pressButton(pxsim.Key.Right);
1092
1077
  else
1093
- visuals.releaseButton(visuals.SimulatorButton.Right);
1078
+ visuals.releaseButton(pxsim.Key.Right);
1094
1079
  }
1095
1080
  }
1096
1081
  }
@@ -1103,10 +1088,10 @@ var pxsim;
1103
1088
  return Math.sqrt(Math.pow(this.handleX - HALF_WIDTH, 2) + Math.pow(this.handleY - HALF_WIDTH, 2));
1104
1089
  }
1105
1090
  clearButtonPresses() {
1106
- visuals.releaseButton(visuals.SimulatorButton.Down);
1107
- visuals.releaseButton(visuals.SimulatorButton.Up);
1108
- visuals.releaseButton(visuals.SimulatorButton.Left);
1109
- visuals.releaseButton(visuals.SimulatorButton.Right);
1091
+ visuals.releaseButton(pxsim.Key.Down);
1092
+ visuals.releaseButton(pxsim.Key.Up);
1093
+ visuals.releaseButton(pxsim.Key.Left);
1094
+ visuals.releaseButton(pxsim.Key.Right);
1110
1095
  this.lastOctet = undefined;
1111
1096
  }
1112
1097
  bindEvent(element, event, callback) {
@@ -1125,19 +1110,6 @@ var pxsim;
1125
1110
  (function (pxsim) {
1126
1111
  var visuals;
1127
1112
  (function (visuals) {
1128
- let SimulatorButton;
1129
- (function (SimulatorButton) {
1130
- SimulatorButton[SimulatorButton["Left"] = 1] = "Left";
1131
- SimulatorButton[SimulatorButton["Up"] = 2] = "Up";
1132
- SimulatorButton[SimulatorButton["Right"] = 3] = "Right";
1133
- SimulatorButton[SimulatorButton["Down"] = 4] = "Down";
1134
- SimulatorButton[SimulatorButton["A"] = 5] = "A";
1135
- SimulatorButton[SimulatorButton["B"] = 6] = "B";
1136
- SimulatorButton[SimulatorButton["Menu"] = 7] = "Menu";
1137
- // system keys
1138
- SimulatorButton[SimulatorButton["Reset"] = -3] = "Reset";
1139
- SimulatorButton[SimulatorButton["TogglePause"] = -4] = "TogglePause";
1140
- })(SimulatorButton = visuals.SimulatorButton || (visuals.SimulatorButton = {}));
1141
1113
  function pressButton(button) {
1142
1114
  pxsim.board().handleKeyEvent(button, true);
1143
1115
  }
@@ -2107,7 +2079,7 @@ var pxsim;
2107
2079
  const rd = new Uint32Array(ca.buffer);
2108
2080
  const src = buf.data;
2109
2081
  if (48 != src.length)
2110
- pxsim.pxtrt.panic(911 /* PANIC_SCREEN_ERROR */);
2082
+ pxsim.pxtrt.panic(911 /* pxsim.PXT_PANIC.PANIC_SCREEN_ERROR */);
2111
2083
  this.palette = new Uint32Array((src.length / 3) | 0);
2112
2084
  for (let i = 0; i < this.palette.length; ++i) {
2113
2085
  const p = i * 3;