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

import {loadMap} from './view/MapLoader';
import Renderer from './view/renderer/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 mapData = new MapData(JSON.parse(this.responseText));
		const map = new MapState(mapData);

		const mapView = await loadMap(renderer, map);
		mapView.render();
	});

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