summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/control')
-rw-r--r--src/control/MapContext.coffee29
-rw-r--r--src/control/MapContext.ts34
2 files changed, 34 insertions, 29 deletions
diff --git a/src/control/MapContext.coffee b/src/control/MapContext.coffee
deleted file mode 100644
index df6efec..0000000
--- a/src/control/MapContext.coffee
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict'
-
-
-Direction = require '../model/Direction'
-Entity = require '../model/Entity'
-EntityPosition = require '../model/EntityPosition'
-Position = require '../model/Position'
-
-MapView = require '../view/MapView'
-
-
-class MapContext
- constructor: (@map) ->
- @entities = {}
-
- @playerEntity = new EntityPosition(
- new Entity('square'),
- new Position(8, 8),
- Direction.EAST)
-
- @addEntity(@playerEntity)
-
- @mavView = new MapView @map, @entities
-
- addEntity: (entity) =>
- @entities[entity.position.asString()] = entity
-
-
-module.exports = MapContext
diff --git a/src/control/MapContext.ts b/src/control/MapContext.ts
new file mode 100644
index 0000000..4bc75c7
--- /dev/null
+++ b/src/control/MapContext.ts
@@ -0,0 +1,34 @@
+'use strict';
+
+
+import Direction from '../model/Direction';
+import Entity from '../model/Entity';
+import EntityPosition from '../model/EntityPosition';
+import MapData from '../model/MapData';
+import Position from '../model/Position';
+
+import MapView from '../view/MapView';
+
+
+export default class MapContext {
+ view: MapView;
+
+ entities: {[key: string]: EntityPosition} = {};
+ playerEntity: EntityPosition;
+
+ constructor(public map: MapData) {
+ this.playerEntity = new EntityPosition(
+ new Entity('square'),
+ new Position(8, 8),
+ Direction.East
+ );
+
+ this.addEntity(this.playerEntity);
+
+ this.view = new MapView(map, this.entities);
+ }
+
+ addEntity(entity: EntityPosition) {
+ this.entities[entity.position.asString()] = entity;
+ }
+}