Skip to content

Commit 0ff1916

Browse files
committed
Formatting cleanup with Prettier
1 parent d0e3fa5 commit 0ff1916

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

src/Sprite.js

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -489,33 +489,34 @@ export class Sprite extends SpriteBase {
489489
let dy = -Math.sin(rad);
490490
switch (nearestEdge) {
491491
case Sprite.Edge.LEFT:
492-
dx = Math.max(0.2, Math.abs(dx));
493-
break;
492+
dx = Math.max(0.2, Math.abs(dx));
493+
break;
494494
case Sprite.Edge.RIGHT:
495-
dx = -Math.max(0.2, Math.abs(dx));
496-
break;
495+
dx = -Math.max(0.2, Math.abs(dx));
496+
break;
497497
case Sprite.Edge.TOP:
498-
dy = Math.max(0.2, Math.abs(dy));
499-
break;
498+
dy = Math.max(0.2, Math.abs(dy));
499+
break;
500500
case Sprite.Edge.BOTTOM:
501-
dy = -Math.max(0.2, Math.abs(dy));
502-
break;
501+
dy = -Math.max(0.2, Math.abs(dy));
502+
break;
503503
}
504504
this.direction = this.degToScratch(this.radToDeg(Math.atan2(dy, dx)));
505-
const {x, y} = this.keepInFence(this.x, this.y);
505+
const { x, y } = this.keepInFence(this.x, this.y);
506506
this.goto(x, y);
507507
}
508508

509509
keepInFence(newX, newY) {
510510
// https://github.com/LLK/scratch-vm/blob/develop/src/sprites/rendered-target.js#L949
511511
const fence = this.stage.fence;
512512
const bounds = this._project.renderer.getBoundingBox(this);
513-
bounds.left += (newX - this.x);
514-
bounds.right += (newX - this.x);
515-
bounds.top += (newY - this.y);
516-
bounds.bottom += (newY - this.y);
513+
bounds.left += newX - this.x;
514+
bounds.right += newX - this.x;
515+
bounds.top += newY - this.y;
516+
bounds.bottom += newY - this.y;
517517

518-
let dx = 0, dy = 0;
518+
let dx = 0,
519+
dy = 0;
519520
if (bounds.left < fence.left) {
520521
dx += fence.left - bounds.left;
521522
}
@@ -528,10 +529,10 @@ export class Sprite extends SpriteBase {
528529
if (bounds.bottom < fence.bottom) {
529530
dy += fence.bottom - bounds.bottom;
530531
}
531-
return ({
532+
return {
532533
x: newX + dx,
533534
y: newY + dy
534-
});
535+
};
535536
}
536537

537538
get penDown() {
@@ -625,35 +626,35 @@ export class Sprite extends SpriteBase {
625626
}
626627

627628
nearestEdge() {
628-
const bounds = this._project.renderer.getBoundingBox(this);
629-
const {width: stageWidth, height: stageHeight} = this.stage;
630-
const distLeft = Math.max(0, (stageWidth / 2) + bounds.left);
631-
const distTop = Math.max(0, (stageHeight / 2) - bounds.top);
632-
const distRight = Math.max(0, (stageWidth / 2) - bounds.right);
633-
const distBottom = Math.max(0, (stageHeight / 2) + bounds.bottom);
634-
// Find the nearest edge.
635-
let nearestEdge = '';
636-
let minDist = Infinity;
637-
if (distLeft < minDist) {
638-
minDist = distLeft;
639-
nearestEdge = Sprite.Edge.LEFT;
640-
}
641-
if (distTop < minDist) {
642-
minDist = distTop;
643-
nearestEdge = Sprite.Edge.TOP;
644-
}
645-
if (distRight < minDist) {
646-
minDist = distRight;
647-
nearestEdge = Sprite.Edge.RIGHT;
648-
}
649-
if (distBottom < minDist) {
650-
minDist = distBottom;
651-
nearestEdge = Sprite.Edge.BOTTOM;
652-
}
653-
if (minDist > 0) {
654-
nearestEdge = null;
655-
}
656-
return nearestEdge;
629+
const bounds = this._project.renderer.getBoundingBox(this);
630+
const { width: stageWidth, height: stageHeight } = this.stage;
631+
const distLeft = Math.max(0, stageWidth / 2 + bounds.left);
632+
const distTop = Math.max(0, stageHeight / 2 - bounds.top);
633+
const distRight = Math.max(0, stageWidth / 2 - bounds.right);
634+
const distBottom = Math.max(0, stageHeight / 2 + bounds.bottom);
635+
// Find the nearest edge.
636+
let nearestEdge = "";
637+
let minDist = Infinity;
638+
if (distLeft < minDist) {
639+
minDist = distLeft;
640+
nearestEdge = Sprite.Edge.LEFT;
641+
}
642+
if (distTop < minDist) {
643+
minDist = distTop;
644+
nearestEdge = Sprite.Edge.TOP;
645+
}
646+
if (distRight < minDist) {
647+
minDist = distRight;
648+
nearestEdge = Sprite.Edge.RIGHT;
649+
}
650+
if (distBottom < minDist) {
651+
minDist = distBottom;
652+
nearestEdge = Sprite.Edge.BOTTOM;
653+
}
654+
if (minDist > 0) {
655+
nearestEdge = null;
656+
}
657+
return nearestEdge;
657658
}
658659

659660
say(text) {

0 commit comments

Comments
 (0)