diff options
Diffstat (limited to 'src/model/data')
-rw-r--r-- | src/model/data/collision.ts | 6 | ||||
-rw-r--r-- | src/model/data/entity.ts | 19 | ||||
-rw-r--r-- | src/model/data/map.ts | 11 |
3 files changed, 28 insertions, 8 deletions
diff --git a/src/model/data/collision.ts b/src/model/data/collision.ts new file mode 100644 index 0000000..5008fa3 --- /dev/null +++ b/src/model/data/collision.ts @@ -0,0 +1,6 @@ +export interface CollisionPolygon { + readonly type: 'polygon'; + readonly vertices: Array<[number, number]>; +} + +export type Collision = CollisionPolygon; diff --git a/src/model/data/entity.ts b/src/model/data/entity.ts new file mode 100644 index 0000000..3474a38 --- /dev/null +++ b/src/model/data/entity.ts @@ -0,0 +1,19 @@ +import { Collision } from './collision'; + +export interface EntityDataInput { + readonly sprite: string; + readonly anchor?: [number, number]; + readonly collision?: Collision[]; +} + +export class EntityData { + public readonly sprite: string; + public readonly anchor: [number, number]; + public readonly collision: Collision[]; + + constructor(input: EntityDataInput) { + this.sprite = input.sprite; + this.anchor = input.anchor || [0.5, 0.5]; + this.collision = input.collision || []; + } +} diff --git a/src/model/data/map.ts b/src/model/data/map.ts index 4d9ecda..b36f6b5 100644 --- a/src/model/data/map.ts +++ b/src/model/data/map.ts @@ -1,11 +1,6 @@ -export interface CollisionPolygon { - readonly type: 'polygon'; - readonly vertices: Array<[number, number]>; -} - -export type Collision = CollisionPolygon; +import { Collision } from './collision'; -export interface Input { +export interface MapDataInput { readonly tiles: string[]; readonly layers: number[][][]; readonly collision: Collision[]; @@ -19,7 +14,7 @@ export class MapData { public readonly width: number; public readonly height: number; - constructor(data: Input) { + constructor(data: MapDataInput) { this.tiles = data.tiles; this.layers = data.layers; this.collision = data.collision; |