Work on various issues
This commit is contained in:
parent
b7afa274f2
commit
a6efbc02b9
2 changed files with 257 additions and 126 deletions
|
|
@ -1,32 +1,42 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { settings } from '../../drawing/settings';
|
||||
import { GameObject } from '../../objects/game-object';
|
||||
import { BoundingBox } from '../bounding-box';
|
||||
import { IShape } from '../i-shape';
|
||||
import { Circle } from './circle';
|
||||
|
||||
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 boundingCircleRadius = 100;
|
||||
|
||||
protected readonly headRadius = 40;
|
||||
protected readonly torsoRadius = 60;
|
||||
protected readonly footRadius = 30;
|
||||
|
||||
protected readonly k = 1000000;
|
||||
|
||||
private readonly headOffset = vec2.fromValues(
|
||||
0,
|
||||
this.headRadius + this.torsoRadius / 2
|
||||
);
|
||||
private readonly torsoOffset = vec2.fromValues(0, 0);
|
||||
private readonly leftFootOffset = vec2.fromValues(-20, -60);
|
||||
private readonly rightFootOffset = vec2.fromValues(20, -60);
|
||||
|
||||
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(), this.boundingCircleRadius);
|
||||
protected head = new Circle(vec2.create(), this.headRadius);
|
||||
protected torso = new Circle(vec2.create(), this.torsoRadius);
|
||||
protected leftFoot = new Circle(vec2.create(), this.footRadius);
|
||||
protected rightFoot = new Circle(vec2.create(), this.footRadius);
|
||||
public constructor(center: vec2, public readonly gameObject: GameObject = null) {
|
||||
this.position = center;
|
||||
}
|
||||
|
||||
public set position(value: vec2) {
|
||||
vec2.copy(this.boundingCircle.center, value);
|
||||
vec2.add(this.head.center, value, Blob.headOffset);
|
||||
vec2.add(this.torso.center, value, Blob.torsoOffset);
|
||||
vec2.add(this.leftFoot.center, value, Blob.leftFootOffset);
|
||||
vec2.add(this.rightFoot.center, value, Blob.rightFootOffset);
|
||||
vec2.add(this.head.center, value, this.headOffset);
|
||||
vec2.add(this.torso.center, value, this.torsoOffset);
|
||||
vec2.add(this.leftFoot.center, value, this.leftFootOffset);
|
||||
vec2.add(this.rightFoot.center, value, this.rightFootOffset);
|
||||
}
|
||||
|
||||
public get center(): vec2 {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { BoundingBox } from '../bounding-box';
|
||||
import { clamp01 } from '../../helper/clamp';
|
||||
import { mix } from '../../helper/mix';
|
||||
import { IShape } from '../i-shape';
|
||||
import { rotate90Deg } from '../../helper/rotate-90-deg';
|
||||
import { GameObject } from '../../objects/game-object';
|
||||
import { BoundingBox } from '../bounding-box';
|
||||
import { IShape } from '../i-shape';
|
||||
|
||||
export default class TunnelShape implements IShape {
|
||||
public readonly isInverted = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue