diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-11-08 22:26:11 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-11-08 22:26:11 +0100 |
commit | e0eddb8741b840df97380e557abd51b47a5e2eee (patch) | |
tree | 43fadcde4292437b14dcece8a0d85da560a4eb94 /src/math | |
parent | 5eae6f29a80cd47e268cb6eaefa96a0ab0a63e54 (diff) | |
download | rpgedit-e0eddb8741b840df97380e557abd51b47a5e2eee.tar rpgedit-e0eddb8741b840df97380e557abd51b47a5e2eee.zip |
Implement circle collidables
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/circle.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/math/circle.ts b/src/math/circle.ts new file mode 100644 index 0000000..f4e855a --- /dev/null +++ b/src/math/circle.ts @@ -0,0 +1,15 @@ +import { Collidable } from './collision'; +import { Movement } from './line'; +import { Point } from './point'; + +import { vec2 } from 'gl-matrix'; + +export class Circle implements Collidable, Point { + private pointCollide = Point.prototype.collide; + + constructor(public readonly p: vec2, public readonly r: number) {} + + public collide(out: vec2, move: Movement, r: number): boolean { + return this.pointCollide(out, move, r + this.r); + } +} |