pxt-microbit 4.1.7 → 4.1.8

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.
package/built/sim.js CHANGED
@@ -3784,7 +3784,7 @@ path.sim-board {
3784
3784
  let pt = this.element.createSVGPoint();
3785
3785
  pxsim.svg.buttonEvents(this.head, (ev) => {
3786
3786
  let cur = pxsim.svg.cursorPoint(pt, this.element, ev);
3787
- state.compassState.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI + 90);
3787
+ state.compassState.heading = 360 - (Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI) + 90) - 360;
3788
3788
  if (state.compassState.heading < 0)
3789
3789
  state.compassState.heading += 360;
3790
3790
  this.updateHeading();
@@ -3793,7 +3793,7 @@ path.sim-board {
3793
3793
  }
3794
3794
  let txt = state.compassState.heading.toString() + "°";
3795
3795
  if (txt != this.headText.textContent) {
3796
- pxsim.svg.rotateElement(this.head, xc, yc, state.compassState.heading + 180);
3796
+ pxsim.svg.rotateElement(this.head, xc, yc, 360 - state.compassState.heading - 180);
3797
3797
  this.headText.textContent = txt;
3798
3798
  if (this.props.runtime)
3799
3799
  this.props.runtime.environmentGlobals[pxsim.localization.lf("heading")] = state.compassState.heading;