Add linting

This commit is contained in:
schmelczerandras 2020-08-18 16:52:11 +02:00
commit 40a660b7cb
3 changed files with 232 additions and 329 deletions

View file

@ -1,5 +1,5 @@
import { BoundingBox } from './bounding-box';
import { vec2 } from 'gl-matrix';
import { BoundingBox } from './bounding-box';
import { GameObject } from '../objects/game-object';
export interface IShape {

View file

@ -7,35 +7,28 @@ import { GameObject } from '../../objects/game-object';
export class Blob implements IShape {
private static readonly boundingCircleRadius = 19;
private static readonly headOffset = vec2.fromValues(0, 15);
private static readonly torsoOffset = vec2.fromValues(0, 0);
private static readonly leftFootOffset = vec2.fromValues(-5, -10);
private static readonly rightFootOffset = vec2.fromValues(5, -10);
public readonly isInverted = false;
protected boundingCircle = new Circle(
vec2.create(),
Blob.boundingCircleRadius
);
protected head = new Circle(vec2.create(), settings.shaderMacros.headRadius);
protected torso = new Circle(
vec2.create(),
settings.shaderMacros.torsoRadius
);
protected leftFoot = new Circle(
vec2.create(),
settings.shaderMacros.footRadius
);
protected rightFoot = new Circle(
vec2.create(),
settings.shaderMacros.footRadius
);
protected boundingCircle = new Circle(vec2.create(), Blob.boundingCircleRadius);
public constructor(
center: vec2,
public readonly gameObject: GameObject = null
) {
protected head = new Circle(vec2.create(), settings.shaderMacros.headRadius);
protected torso = new Circle(vec2.create(), settings.shaderMacros.torsoRadius);
protected leftFoot = new Circle(vec2.create(), settings.shaderMacros.footRadius);
protected rightFoot = new Circle(vec2.create(), settings.shaderMacros.footRadius);
public constructor(center: vec2, public readonly gameObject: GameObject = null) {
this.position = center;
}

View file

@ -6,7 +6,7 @@ import { IShape } from '../i-shape';
import { rotate90Deg } from '../../helper/rotate-90-deg';
import { GameObject } from '../../objects/game-object';
export class TunnelShape implements IShape {
export default class TunnelShape implements IShape {
public readonly isInverted = true;
public readonly toFromDelta: vec2;
@ -22,22 +22,10 @@ export class TunnelShape implements IShape {
}
public get boundingBox(): BoundingBox {
const xMin = Math.min(
this.from.x - this.fromRadius,
this.to.x - this.toRadius
);
const yMin = Math.min(
this.from.y - this.fromRadius,
this.to.y - this.toRadius
);
const xMax = Math.max(
this.from.x + this.fromRadius,
this.to.x + this.toRadius
);
const yMax = Math.max(
this.from.y + this.fromRadius,
this.to.y + this.toRadius
);
const xMin = Math.min(this.from.x - this.fromRadius, this.to.x - this.toRadius);
const yMin = Math.min(this.from.y - this.fromRadius, this.to.y - this.toRadius);
const xMax = Math.max(this.from.x + this.fromRadius, this.to.x + this.toRadius);
const yMax = Math.max(this.from.y + this.fromRadius, this.to.y + this.toRadius);
return new BoundingBox(this, xMin, xMax, yMin, yMax);
}
@ -58,8 +46,7 @@ export class TunnelShape implements IShape {
vec2.subtract(diff, target, this.from);
} else {
const side = Math.sign(
this.toFromDelta.x * targetFromDelta.y -
this.toFromDelta.y * targetFromDelta.x
this.toFromDelta.x * targetFromDelta.y - this.toFromDelta.y * targetFromDelta.x
);
const normal = rotate90Deg(this.toFromDelta);
@ -77,9 +64,7 @@ export class TunnelShape implements IShape {
vec2.scale(vec2.create(), normal, side * this.toRadius)
);
diff = rotate90Deg(
vec2.subtract(vec2.create(), translatedTo, translatedFrom)
);
diff = rotate90Deg(vec2.subtract(vec2.create(), translatedTo, translatedFrom));
vec2.scale(diff, diff, side);
}
@ -96,10 +81,8 @@ export class TunnelShape implements IShape {
);
return (
vec2.distance(
targetFromDelta,
vec2.scale(vec2.create(), this.toFromDelta, h)
) - mix(this.fromRadius, this.toRadius, h)
vec2.distance(targetFromDelta, vec2.scale(vec2.create(), this.toFromDelta, h)) -
mix(this.fromRadius, this.toRadius, h)
);
}