summaryrefslogtreecommitdiffstats
path: root/src/app.ts
blob: acd255a4a7286d301ebc5b67f35220b8cb4509bc (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
30
31
32
33
34
35
36
37
38
'use strict';


require('./style.css');


import * as lodash from 'lodash';
_ = lodash;

import MapContext from './control/MapContext';
import MapData from './model/MapData';
import InputHandler from './view/InputHandler';

import * as util from './util';


var relevantKeys = [
        InputHandler.Up,
        InputHandler.Right,
        InputHandler.Down,
        InputHandler.Left,
];


var mapContext: MapContext;

window.onload = () => {
        var xhr = new XMLHttpRequest();

        xhr.onload = function() {
                var mapDef = new MapData(JSON.parse(this.responseText));
                var inputHandler = new InputHandler(util.arrayToObject(relevantKeys));
                mapContext = new MapContext(mapDef, inputHandler);
        }

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