38 lines
841 B
TypeScript
38 lines
841 B
TypeScript
'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.numberArrayToMap(relevantKeys));
|
|
mapContext = new MapContext(mapDef, inputHandler);
|
|
}
|
|
|
|
xhr.open('GET', 'resources/map/test.json', true);
|
|
xhr.send();
|
|
};
|