summaryrefslogtreecommitdiffstats
path: root/src/model/data/MapData.ts
blob: 0f14f5070ce0386c4875843ce355c311e7f33003 (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
import {mapFromObject} from '../../util';

interface Input {
	readonly tiles: {[key: string]: string};
	readonly collision: string[];
	readonly layers: string[][][];
}

export default class MapData {
	public readonly tiles: Map<string, string>;
	public readonly collision: string[];
	public readonly layers: string[][][];

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

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

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