Skip to content

Commit

Permalink
feat: better eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Prozi committed Nov 1, 2024
1 parent ee73508 commit 44a8cd9
Show file tree
Hide file tree
Showing 14 changed files with 814 additions and 481 deletions.
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

154 changes: 77 additions & 77 deletions dist/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4248,9 +4248,9 @@ class Stress {

// observer #debug & add filtering checkbox event
if (win.MutationObserver) {
const observer = new win.MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
const observer = new win.MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.id == "debug") {
document
.querySelector("#filtering")
Expand Down Expand Up @@ -4387,81 +4387,81 @@ class Stress {
};

let body;
let variant = this.lastVariant++ % 5;
const variant = this.lastVariant++ % 5;

switch (variant) {
case 0:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Circle);
}
body = this.physics.createCircle(
{ x, y },
random(minSize, maxSize) / 2,
options,
);
case 0:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Circle);
}
body = this.physics.createCircle(
{ x, y },
random(minSize, maxSize) / 2,
options,
);

++this.circles;
break;
++this.circles;
break;

case 1:
const width = random(minSize, maxSize);
const height = random(minSize, maxSize);
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Ellipse);
console.log();
}
body = this.physics.createEllipse({ x, y }, width, height, 2, options);
case 1:
const width = random(minSize, maxSize);
const height = random(minSize, maxSize);
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Ellipse);
console.log();
}
body = this.physics.createEllipse({ x, y }, width, height, 2, options);

++this.ellipses;
break;
++this.ellipses;
break;

case 2:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Box);
}
body = this.physics.createBox(
{ x, y },
random(minSize, maxSize),
random(minSize, maxSize),
options,
);
case 2:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Box);
}
body = this.physics.createBox(
{ x, y },
random(minSize, maxSize),
random(minSize, maxSize),
options,
);

++this.boxes;
break;
++this.boxes;
break;

case 3:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Line);
}
body = this.physics.createLine(
{ x, y },
{
x: x + random(minSize, maxSize),
y: y + random(minSize, maxSize),
},
options,
);
case 3:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Line);
}
body = this.physics.createLine(
{ x, y },
{
x: x + random(minSize, maxSize),
y: y + random(minSize, maxSize),
},
options,
);

++this.lines;
break;
++this.lines;
break;

default:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Polygon);
}
body = this.physics.createPolygon(
{ x, y },
[
{ x: -random(minSize, maxSize), y: random(minSize, maxSize) },
{ x: random(minSize, maxSize), y: random(minSize, maxSize) },
{ x: random(minSize, maxSize), y: -random(minSize, maxSize) },
{ x: -random(minSize, maxSize), y: -random(minSize, maxSize) },
],
options,
);
default:
if (this.enableFiltering) {
options.group = groupBits(BodyGroup.Polygon);
}
body = this.physics.createPolygon(
{ x, y },
[
{ x: -random(minSize, maxSize), y: random(minSize, maxSize) },
{ x: random(minSize, maxSize), y: random(minSize, maxSize) },
{ x: random(minSize, maxSize), y: -random(minSize, maxSize) },
{ x: -random(minSize, maxSize), y: -random(minSize, maxSize) },
],
options,
);

++this.polygons;
break;
++this.polygons;
break;
}

// set initial rotation angle direction
Expand Down Expand Up @@ -4647,7 +4647,7 @@ class Tank {
const hit = this.physics.raycast(
this.playerTurret.start,
this.playerTurret.end,
(test) => test !== this.player,
test => test !== this.player,
);

this.drawCallback = () => {
Expand All @@ -4664,16 +4664,16 @@ class Tank {
const player =
Math.random() < 0.5
? this.physics.createCircle(
{ x: this.scaleX(x), y: this.scaleY(y) },
this.scaleX(size / 2),
{ isCentered: true },
)
{ x: this.scaleX(x), y: this.scaleY(y) },
this.scaleX(size / 2),
{ isCentered: true },
)
: this.physics.createBox(
{ x: this.scaleX(x - size / 2), y: this.scaleY(y - size / 2) },
this.scaleX(size),
this.scaleX(size),
{ isCentered: true },
);
{ x: this.scaleX(x - size / 2), y: this.scaleY(y - size / 2) },
this.scaleX(size),
this.scaleX(size),
{ isCentered: true },
);

player.velocity = 0;
player.setOffset({ x: -this.scaleX(size / 2), y: 0 });
Expand Down
8 changes: 4 additions & 4 deletions dist/demo/stress.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class Stress {
this.updateBody = this.updateBody.bind(this);
// observer #debug & add filtering checkbox event
if (win.MutationObserver) {
const observer = new win.MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
const observer = new win.MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.id == "debug") {
document
.querySelector("#filtering")
Expand Down Expand Up @@ -156,7 +156,7 @@ class Stress {
padding: (minSize + maxSize) * 0.2,
};
let body;
let variant = this.lastVariant++ % 5;
const variant = this.lastVariant++ % 5;
switch (variant) {
case 0:
if (this.enableFiltering) {
Expand Down
Loading

0 comments on commit 44a8cd9

Please sign in to comment.