summaryrefslogtreecommitdiffstats
path: root/src/index.ts
blob: 1c2035f2ce44074c710cdf5933ece7212df3be27 (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
import MapData from './model/MapData';

import {loadMap} from './view/MapLoader';
import Renderer from './view/Renderer';

window.onload = () => {
	const canvas = document.getElementById('rpgedit') as HTMLCanvasElement;
	if (!canvas)
		return;

	const renderer = new Renderer(canvas);

	const xhr = new XMLHttpRequest();

	xhr.addEventListener('load', async function() {
		const mapDef = new MapData(JSON.parse(this.responseText));

		const mapView = await loadMap(renderer, mapDef);
		mapView.draw();
	});

	xhr.open('GET', 'resources/map/test.json', true);
	xhr.send();
};