summaryrefslogtreecommitdiffstats
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/index.ts b/src/index.ts
index 3e7f33d..b4109e6 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,23 +1,17 @@
import MapData from './model/data/MapData';
+import { getJSON } from './util';
import { loadMap } from './view/map';
import Renderer from './view/renderer/Renderer';
-window.onload = () => {
+window.onload = async () => {
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 map = new MapData(JSON.parse(this.responseText));
- const mapView = await loadMap(renderer, map);
- mapView.render();
- });
-
- xhr.open('GET', 'resources/map/test.json', true);
- xhr.send();
+ const map = new MapData(await getJSON('resources/map/test.json'));
+ const mapView = await loadMap(renderer, map);
+ mapView.render();
};