summaryrefslogtreecommitdiffstats
path: root/src/model/data/map.ts
blob: 4d9ecda9e9b9324e06d487701a434669ca9ca639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export interface CollisionPolygon {
	readonly type: 'polygon';
	readonly vertices: Array<[number, number]>;
}

export type Collision = CollisionPolygon;

export interface Input {
	readonly tiles: string[];
	readonly layers: number[][][];
	readonly collision: Collision[];
}

export class MapData {
	public readonly tiles: string[];
	public readonly layers: number[][][];
	public readonly collision: Collision[];

	public readonly width: number;
	public readonly height: number;

	constructor(data: Input) {
		this.tiles = data.tiles;
		this.layers = data.layers;
		this.collision = data.collision;

		this.height = this.layers[0].length;
		this.width = this.layers[0][0].length;
	}
}