Setup formatting
This commit is contained in:
parent
d34f25295c
commit
dd850d11d1
45 changed files with 230 additions and 190 deletions
|
|
@ -44,14 +44,14 @@ export class CharacterPhysical extends CharacterBase implements Physical {
|
|||
vec2.clone(CharacterPhysical.leftFootOffset),
|
||||
20,
|
||||
null,
|
||||
container
|
||||
container,
|
||||
),
|
||||
new CirclePhysical(
|
||||
vec2.clone(CharacterPhysical.rightFootOffset),
|
||||
20,
|
||||
null,
|
||||
container
|
||||
)
|
||||
container,
|
||||
),
|
||||
);
|
||||
|
||||
this.head.owner = this;
|
||||
|
|
@ -89,7 +89,7 @@ export class CharacterPhysical extends CharacterBase implements Physical {
|
|||
|
||||
const movementForce = this.movementActions.reduce(
|
||||
(sum, current) => vec2.add(sum, sum, current.delta),
|
||||
vec2.create()
|
||||
vec2.create(),
|
||||
);
|
||||
|
||||
vec2.scale(movementForce, movementForce, 1 / this.movementActions.length);
|
||||
|
|
@ -113,25 +113,25 @@ export class CharacterPhysical extends CharacterBase implements Physical {
|
|||
const bodyCenter = vec2.sub(
|
||||
vec2.create(),
|
||||
this.head.center,
|
||||
CharacterPhysical.headOffset
|
||||
CharacterPhysical.headOffset,
|
||||
);
|
||||
|
||||
const leftFootPositon = vec2.add(
|
||||
vec2.create(),
|
||||
bodyCenter,
|
||||
CharacterPhysical.leftFootOffset
|
||||
CharacterPhysical.leftFootOffset,
|
||||
);
|
||||
const rightFootPositon = vec2.add(
|
||||
vec2.create(),
|
||||
bodyCenter,
|
||||
CharacterPhysical.rightFootOffset
|
||||
CharacterPhysical.rightFootOffset,
|
||||
);
|
||||
|
||||
const leftFootDelta = vec2.sub(vec2.create(), this.leftFoot.center, leftFootPositon);
|
||||
const rightFootDelta = vec2.sub(
|
||||
vec2.create(),
|
||||
this.rightFoot.center,
|
||||
rightFootPositon
|
||||
rightFootPositon,
|
||||
);
|
||||
|
||||
vec2.scale(leftFootDelta, leftFootDelta, 0.0006);
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ export class CirclePhysical implements Circle, Physical {
|
|||
private _center: vec2,
|
||||
private _radius: number,
|
||||
public owner: GameObject,
|
||||
private readonly container: PhysicalContainer
|
||||
private readonly container: PhysicalContainer,
|
||||
) {
|
||||
this._boundingBox = new BoundingBox(null);
|
||||
this._boundingBox = new BoundingBox();
|
||||
this.recalculateBoundingBox();
|
||||
}
|
||||
|
||||
|
|
@ -93,8 +93,8 @@ export class CirclePhysical implements Circle, Physical {
|
|||
result.push(
|
||||
vec2.fromValues(
|
||||
Math.cos((2 * Math.PI * i) / count) * this.radius + this.center.x,
|
||||
Math.sin((2 * Math.PI * i) / count) * this.radius + this.center.y
|
||||
)
|
||||
Math.sin((2 * Math.PI * i) / count) * this.radius + this.center.y,
|
||||
),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
|
|
@ -111,13 +111,13 @@ export class CirclePhysical implements Circle, Physical {
|
|||
vec2.add(
|
||||
this.velocity,
|
||||
this.velocity,
|
||||
vec2.scale(vec2.create(), force, timeInMilliseconds)
|
||||
vec2.scale(vec2.create(), force, timeInMilliseconds),
|
||||
);
|
||||
|
||||
vec2.set(
|
||||
this.velocity,
|
||||
clamp(this.velocity.x, -settings.maxVelocityX, settings.maxVelocityX),
|
||||
clamp(this.velocity.y, -settings.maxVelocityY, settings.maxVelocityY)
|
||||
clamp(this.velocity.y, -settings.maxVelocityY, settings.maxVelocityY),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ export class CirclePhysical implements Circle, Physical {
|
|||
vec2.scale(
|
||||
this.velocity,
|
||||
this.velocity,
|
||||
Math.pow(settings.velocityAttenuation, timeInMilliseconds)
|
||||
Math.pow(settings.velocityAttenuation, timeInMilliseconds),
|
||||
);
|
||||
|
||||
const distance = vec2.scale(vec2.create(), this.velocity, timeInMilliseconds);
|
||||
|
|
@ -140,13 +140,13 @@ export class CirclePhysical implements Circle, Physical {
|
|||
let wasHit = false;
|
||||
|
||||
for (let i = 0; i < stepCount; i++) {
|
||||
const { normal, tangent, hitSurface } = moveCircle(
|
||||
const { tangent, hitSurface } = moveCircle(
|
||||
this,
|
||||
distance,
|
||||
this.container.findIntersecting(this.boundingBox)
|
||||
this.container.findIntersecting(this.boundingBox),
|
||||
);
|
||||
if (hitSurface) {
|
||||
vec2.scale(this.velocity, tangent, vec2.dot(tangent, this.velocity));
|
||||
vec2.scale(this.velocity, tangent!, vec2.dot(tangent!, this.velocity));
|
||||
wasHit = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export class LampPhysical extends LampBase implements Physical {
|
|||
this.center.x - settings.lightCutoffDistance,
|
||||
this.center.x + settings.lightCutoffDistance,
|
||||
this.center.y - settings.lightCutoffDistance,
|
||||
this.center.y + settings.lightCutoffDistance
|
||||
this.center.y + settings.lightCutoffDistance,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class TunnelPhysical extends TunnelBase implements StaticPhysical {
|
|||
const targetFromDelta = vec2.subtract(vec2.create(), target, this.from);
|
||||
|
||||
const h = clamp01(
|
||||
vec2.dot(targetFromDelta, toFromDelta) / vec2.dot(toFromDelta, toFromDelta)
|
||||
vec2.dot(targetFromDelta, toFromDelta) / vec2.dot(toFromDelta, toFromDelta),
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue