Update physics
This commit is contained in:
parent
1b7dee4be0
commit
d9d8d03c36
30 changed files with 447 additions and 552 deletions
21
frontend/src/scripts/physics/physical-object.ts
Normal file
21
frontend/src/scripts/physics/physical-object.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { GameObject } from '../objects/game-object';
|
||||
import { BoundingBoxBase } from './bounds/bounding-box-base';
|
||||
import { Physics } from './physics';
|
||||
|
||||
export abstract class PhysicalObject extends GameObject {
|
||||
public abstract getBoundingBox(): BoundingBoxBase;
|
||||
public abstract distance(target: vec2): number;
|
||||
|
||||
constructor(protected physics: Physics, public readonly canCollide: boolean) {
|
||||
super();
|
||||
}
|
||||
|
||||
protected addToPhysics(isDynamic = false) {
|
||||
if (isDynamic) {
|
||||
this.physics.addDynamicBoundingBox(this.getBoundingBox());
|
||||
} else {
|
||||
this.physics.addStaticBoundingBox(this.getBoundingBox());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue