Fix physics

This commit is contained in:
schmelczerandras 2020-10-12 20:49:17 +02:00
commit f9f6825776
6 changed files with 820 additions and 529 deletions

View file

@ -1,8 +1,5 @@
import { CommandReceiver } from '../commands/command-receiver';
import { Id } from '../transport/identity';
export abstract class GameObject extends CommandReceiver {
constructor(public readonly id: Id) {
super();
}
export abstract class GameObject {
constructor(public readonly id: Id) {}
}

View file

@ -7,6 +7,7 @@ import { GameObject } from '../game-object';
export class CharacterBase extends GameObject {
constructor(
id: Id,
public colorIndex: number,
public head?: Circle,
public leftFoot?: Circle,
public rightFoot?: Circle,
@ -15,7 +16,7 @@ export class CharacterBase extends GameObject {
}
public toArray(): Array<any> {
const { id, head, leftFoot, rightFoot } = this as any;
return [id, head, leftFoot, rightFoot];
const { id, colorIndex, head, leftFoot, rightFoot } = this;
return [id, colorIndex, head, leftFoot, rightFoot];
}
}

View file

@ -9,7 +9,7 @@ export class LampBase extends GameObject {
}
public toArray(): Array<any> {
const { id, center, color, lightness } = this as any;
const { id, center, color, lightness } = this;
return [id, center, color, lightness];
}
}

View file

@ -0,0 +1,15 @@
import { vec2 } from 'gl-matrix';
import { Id } from '../../transport/identity';
import { serializable } from '../../transport/serialization/serializable';
import { GameObject } from '../game-object';
@serializable
export class ProjectileBase extends GameObject {
constructor(id: Id, public center: vec2, public radius: number) {
super(id);
}
public toArray(): Array<any> {
return [this.id, this.center, this.radius];
}
}

View file

@ -0,0 +1,15 @@
import { vec2 } from 'gl-matrix';
import { Id } from '../../transport/identity';
import { serializable } from '../../transport/serialization/serializable';
import { GameObject } from '../game-object';
@serializable
export class StoneBase extends GameObject {
constructor(id: Id, public readonly vertices: Array<vec2>) {
super(id);
}
public toArray(): Array<any> {
return [this.id, this.vertices];
}
}

View file

@ -1,22 +0,0 @@
import { vec2 } from 'gl-matrix';
import { Id } from '../../transport/identity';
import { serializable } from '../../transport/serialization/serializable';
import { GameObject } from '../game-object';
@serializable
export class TunnelBase extends GameObject {
constructor(
id: Id,
public readonly from: vec2,
public readonly to: vec2,
public readonly fromRadius: number,
public readonly toRadius: number,
) {
super(id);
}
public toArray(): Array<any> {
const { id, from, to, fromRadius, toRadius } = this as any;
return [id, from, to, fromRadius, toRadius];
}
}