Fix issues
This commit is contained in:
parent
57d7009342
commit
42e4de28b5
15 changed files with 175 additions and 145 deletions
|
|
@ -7,7 +7,6 @@ import { ViewObject } from './view-object';
|
|||
|
||||
export class Camera extends GameObject implements ViewObject {
|
||||
public center: vec2 = vec2.create();
|
||||
|
||||
private aspectRatio?: number;
|
||||
|
||||
constructor(private game: Game) {
|
||||
|
|
@ -15,12 +14,10 @@ export class Camera extends GameObject implements ViewObject {
|
|||
}
|
||||
|
||||
public updateProperties(update: UpdateProperty[]): void {}
|
||||
|
||||
public step(deltaTimeInSeconds: number): void {}
|
||||
public beforeDestroy(): void {}
|
||||
|
||||
public step(deltaTimeInSeconds: number): void {}
|
||||
|
||||
public draw(renderer: Renderer, overlay: HTMLElement, shouldChangeLayout: boolean) {
|
||||
public draw(renderer: Renderer) {
|
||||
const canvasAspectRatio = renderer.canvasSize.x / renderer.canvasSize.y;
|
||||
if (canvasAspectRatio !== this.aspectRatio) {
|
||||
this.aspectRatio = canvasAspectRatio;
|
||||
|
|
|
|||
|
|
@ -14,19 +14,17 @@ type FallingPoint = {
|
|||
|
||||
export class PlanetView extends PlanetBase implements ViewObject {
|
||||
private shape: PlanetShape;
|
||||
private ownershipProgess: HTMLElement;
|
||||
private ownershipProgress: HTMLElement;
|
||||
|
||||
constructor(id: Id, vertices: Array<vec2>, ownership: number) {
|
||||
super(id, vertices);
|
||||
this.shape = new PlanetShape(vertices, ownership);
|
||||
(this.shape as any).randomOffset = Random.getRandom();
|
||||
|
||||
this.ownershipProgess = document.createElement('div');
|
||||
this.ownershipProgess.className = 'ownership';
|
||||
this.ownershipProgress = document.createElement('div');
|
||||
this.ownershipProgress.className = 'ownership';
|
||||
}
|
||||
|
||||
public updateProperties(update: UpdateProperty[]): void {}
|
||||
|
||||
public step(deltaTimeInSeconds: number): void {
|
||||
this.shape.randomOffset += deltaTimeInSeconds / 4;
|
||||
this.shape.colorMixQ = this.ownership;
|
||||
|
|
@ -56,20 +54,26 @@ export class PlanetView extends PlanetBase implements ViewObject {
|
|||
}
|
||||
|
||||
public beforeDestroy(): void {
|
||||
this.ownershipProgess.parentElement?.removeChild(this.ownershipProgess);
|
||||
this.ownershipProgress.parentElement?.removeChild(this.ownershipProgress);
|
||||
this.generatedPointElements.forEach((p) =>
|
||||
p.element.parentElement?.removeChild(p.element),
|
||||
);
|
||||
}
|
||||
|
||||
public updateProperties(update: UpdateProperty[]): void {
|
||||
update.forEach((u) => {
|
||||
this.ownership = u.propertyValue;
|
||||
});
|
||||
}
|
||||
|
||||
public draw(
|
||||
renderer: Renderer,
|
||||
overlay: HTMLElement,
|
||||
shouldChangeLayout: boolean,
|
||||
): void {
|
||||
if (shouldChangeLayout) {
|
||||
if (!this.ownershipProgess.parentElement) {
|
||||
overlay.appendChild(this.ownershipProgess);
|
||||
if (!this.ownershipProgress.parentElement) {
|
||||
overlay.appendChild(this.ownershipProgress);
|
||||
}
|
||||
|
||||
const screenPosition = renderer.worldToDisplayCoordinates(this.center);
|
||||
|
|
@ -94,8 +98,8 @@ export class PlanetView extends PlanetBase implements ViewObject {
|
|||
(p) => p.timeToLive > 0,
|
||||
);
|
||||
|
||||
this.ownershipProgess.style.transform = `translateX(${screenPosition.x}px) translateY(${screenPosition.y}px) translateX(-50%) translateY(-50%)`;
|
||||
this.ownershipProgess.style.background = this.getGradient();
|
||||
this.ownershipProgress.style.transform = `translateX(${screenPosition.x}px) translateY(${screenPosition.y}px) translateX(-50%) translateY(-50%)`;
|
||||
this.ownershipProgress.style.background = this.getGradient();
|
||||
|
||||
if (this.lastGeneratedPoint !== undefined) {
|
||||
const element = document.createElement('div');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue