Skip to content

Commit

Permalink
fixed eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rlszabo committed Mar 28, 2023
1 parent 460652f commit 53ea5a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
12 changes: 5 additions & 7 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,12 @@ export function activate(context: vscode.ExtensionContext) {
);

context.subscriptions.push(
vscode.commands.registerCommand('vscode-pets.throw-with-mouse',
() => {
const panel = getPetPanel();
if (panel !== undefined) {
panel.setThrowWithMouse(true);
}
vscode.commands.registerCommand('vscode-pets.throw-with-mouse', () => {
const panel = getPetPanel();
if (panel !== undefined) {
panel.setThrowWithMouse(true);
}
),
}),
);

context.subscriptions.push(
Expand Down
6 changes: 2 additions & 4 deletions src/panel/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,12 @@ export function petPanelApp(

/// Bouncing ball components, credit https://stackoverflow.com/a/29982343
const gravity: number = 0.6,
damping: number = 0.90,
damping: number = 0.9,
traction: number = 0.8,
interval: number = 1000 / 24; // msec for single frame
let then: number = 0; // last draw
var ballState: BallState;


function resetBall() {
if (ballState) {
ballState.paused = true;
Expand Down Expand Up @@ -411,7 +410,7 @@ export function petPanelApp(
endMouseX,
endMouseY,
endMouseX - startMouseX,
endMouseY - startMouseY
endMouseY - startMouseY,
);
allPets.pets.forEach((petEl) => {
if (petEl.pet.canChase) {
Expand All @@ -433,7 +432,6 @@ export function petPanelApp(
}
}


function throwBall() {
if (!ballState.paused) {
requestAnimationFrame(throwBall);
Expand Down
27 changes: 18 additions & 9 deletions src/panel/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,20 @@ export class BallState {
vy: number;
paused: boolean;

constructor(cx: number, cy: number, vx: number, vy: number, randomize?: boolean) {
constructor(
cx: number,
cy: number,
vx: number,
vy: number,
randomize?: boolean,
) {
if (randomize !== undefined && randomize === true) {
const rVals = this.randomizeBallState();
this.cx = rVals[0];
this.cy = rVals[1];
this.vx = rVals[2];
this.vy = rVals[3];
}
else {
} else {
this.cx = cx;
this.cy = cy;
this.vx = vx;
Expand All @@ -111,14 +116,18 @@ export class BallState {

private randomizeBallState(): Array<number> {
/* velocity */
const randVx: Array<number> = [ //avoids values close to 0
const randVx: Array<number> = [
//avoids values close to 0
-1 * (Math.floor(Math.random() * 12) + 3), //left
Math.floor(Math.random() * 12) + 3 // right
];
const randVy: number = Math.floor((Math.random() * 20) - 10);
Math.floor(Math.random() * 12) + 3, // right
];
const randVy: number = Math.floor(Math.random() * 20 - 10);
/* position */
const randX: number = Math.floor(Math.random() * (window.innerWidth * 0.80) + 10);
const randY: number = Math.floor(Math.random() * (window.innerHeight * 0.60)) + 30;
const randX: number = Math.floor(
Math.random() * (window.innerWidth * 0.8) + 10,
);
const randY: number =
Math.floor(Math.random() * (window.innerHeight * 0.6)) + 30;

/* flip a coin to throw left or right */
const coin: number = Math.floor(Math.random() * 2);
Expand Down

0 comments on commit 53ea5a8

Please sign in to comment.