summaryrefslogtreecommitdiffstats
path: root/src/renderer/runtime/model/data/map.ts
blob: 81ce051453ac21788c304cb5e0f06a87562040f7 (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
import { Collision } from './collision';

export interface MapLayer {
	readonly tiles: number[][];
}

export interface MapDataInput {
	readonly tiles: string[];
	readonly layers: MapLayer[];
	readonly collision: Collision[];
}

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

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

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

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