diff options
Diffstat (limited to 'src/controller/entitycontext.ts')
-rw-r--r-- | src/controller/entitycontext.ts | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/controller/entitycontext.ts b/src/controller/entitycontext.ts deleted file mode 100644 index 434bf9b..0000000 --- a/src/controller/entitycontext.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { EntityView } from '../view/entity'; -import { Renderer } from '../view/renderer/renderer'; - -import { Collidable } from '../math/collision'; - -import { CollidableGroup, mkCollision } from './collision'; - -import { vec2 } from 'gl-matrix'; - -export class EntityContext implements CollidableGroup { - public static async load(renderer: Renderer, name: string): Promise<EntityContext> { - return new EntityContext( - renderer, - name, - await EntityView.load(renderer, name), - ); - } - - public readonly pos: vec2 = vec2.create(); - - private readonly collision: Collidable[]; - - private constructor( - private readonly renderer: Renderer, - private readonly name: string, - private readonly view: EntityView, - ) { - this.collision = mkCollision(view.data.collision); - } - - public render(time: number) { - this.renderer.setTranslation(this.pos); - this.view.renderByTime(time); - } - - public getTranslation(): vec2 { - return this.pos; - } - - public getCollidables(): Collidable[] { - return this.collision; - } - - public interact() { - alert(`You've interacted with ${this.name}!`); - } -} |