Tweak code
This commit is contained in:
parent
b6bef3c77d
commit
edd7d4836e
4 changed files with 39 additions and 48 deletions
|
|
@ -7,6 +7,7 @@ export interface Line {}
|
|||
|
||||
export class Tunnel extends GameObject {
|
||||
private boundingCircle: Circle;
|
||||
private tangent: vec2;
|
||||
|
||||
constructor(
|
||||
private from: vec2,
|
||||
|
|
@ -20,12 +21,15 @@ export class Tunnel extends GameObject {
|
|||
vec2.fromValues(from.x / 2 + to.x / 2, from.y / 2 + to.y / 2),
|
||||
radiusFrom + radiusTo + vec2.distance(from, to)
|
||||
);
|
||||
|
||||
this.tangent = vec2.subtract(vec2.create(), to, from);
|
||||
|
||||
this.addCommandExecutor(DrawCommand, this.draw.bind(this));
|
||||
}
|
||||
|
||||
private draw(c: DrawCommand) {
|
||||
if (c.drawer.isOnScreen(this.boundingCircle)) {
|
||||
c.drawer.appendToUniformList('lines', this.from, this.to);
|
||||
c.drawer.appendToUniformList('lines', this.from, this.tangent);
|
||||
c.drawer.appendToUniformList('radii', this.radiusFrom, this.radiusTo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue