diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/Direction.coffee | 13 | ||||
-rw-r--r-- | src/model/Direction.ts | 13 | ||||
-rw-r--r-- | src/model/Entity.coffee | 8 | ||||
-rw-r--r-- | src/model/Entity.ts | 6 | ||||
-rw-r--r-- | src/model/EntityPosition.coffee | 8 | ||||
-rw-r--r-- | src/model/EntityPosition.ts | 11 | ||||
-rw-r--r-- | src/model/MapData.coffee | 9 | ||||
-rw-r--r-- | src/model/MapData.ts | 20 | ||||
-rw-r--r-- | src/model/Position.coffee | 10 | ||||
-rw-r--r-- | src/model/Position.ts | 10 |
10 files changed, 60 insertions, 48 deletions
diff --git a/src/model/Direction.coffee b/src/model/Direction.coffee deleted file mode 100644 index 5c49c80..0000000 --- a/src/model/Direction.coffee +++ /dev/null @@ -1,13 +0,0 @@ -'use strict' - - -Direction = - NORTH: 0 - EAST: 1 - SOUTH: 2 - WEST: 3 - - reverse: (d) -> (d+2)%4 - - -module.exports = Direction diff --git a/src/model/Direction.ts b/src/model/Direction.ts new file mode 100644 index 0000000..a0cf45d --- /dev/null +++ b/src/model/Direction.ts @@ -0,0 +1,13 @@ +'use strict'; + + +export enum Direction { + North, + East, + South, + West +}; + +export function reverse(r: Direction): Direction { return (r+2) % 4; } + +export default Direction; diff --git a/src/model/Entity.coffee b/src/model/Entity.coffee deleted file mode 100644 index 70c81fa..0000000 --- a/src/model/Entity.coffee +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' - - -class Entity - constructor: (@name) -> - - -module.exports = Entity diff --git a/src/model/Entity.ts b/src/model/Entity.ts new file mode 100644 index 0000000..b9a52eb --- /dev/null +++ b/src/model/Entity.ts @@ -0,0 +1,6 @@ +'use strict'; + + +export default class Entity { + constructor(public name: string) {} +} diff --git a/src/model/EntityPosition.coffee b/src/model/EntityPosition.coffee deleted file mode 100644 index aaf9531..0000000 --- a/src/model/EntityPosition.coffee +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' - - -class EntityPosition - constructor: (@entity, @position, @direction) -> - - -module.exports = EntityPosition diff --git a/src/model/EntityPosition.ts b/src/model/EntityPosition.ts new file mode 100644 index 0000000..815eceb --- /dev/null +++ b/src/model/EntityPosition.ts @@ -0,0 +1,11 @@ +'use strict'; + + +import Direction from '../model/Direction'; +import Entity from './Entity'; +import Position from './Position'; + + +export default class EntityPosition { + constructor(public entity: Entity, public position: Position, public direction: Direction) {} +} diff --git a/src/model/MapData.coffee b/src/model/MapData.coffee deleted file mode 100644 index 39b2140..0000000 --- a/src/model/MapData.coffee +++ /dev/null @@ -1,9 +0,0 @@ -'use strict' - - -class MapData - constructor: (data) -> - {@tiles, @collition, @layers} = data - - -module.exports = MapData diff --git a/src/model/MapData.ts b/src/model/MapData.ts new file mode 100644 index 0000000..54894c0 --- /dev/null +++ b/src/model/MapData.ts @@ -0,0 +1,20 @@ +'use strict'; + + +interface Input { + tiles: {[key: string]: {file: string}}; + collision: string[]; + layers: string[][][]; +} + +export default class MapData { + tiles: {[key: string]: {file: string}}; + public collision: string[]; + public layers: string[][][]; + + constructor(data: Input) { + this.tiles = data.tiles; + this.collision = data.collision; + this.layers = data.layers; + } +} diff --git a/src/model/Position.coffee b/src/model/Position.coffee deleted file mode 100644 index 08bb999..0000000 --- a/src/model/Position.coffee +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - - -class Position - constructor: (@x, @y) -> - - asString: => "#{@x},#{@y}" - - -module.exports = Position diff --git a/src/model/Position.ts b/src/model/Position.ts new file mode 100644 index 0000000..1db37af --- /dev/null +++ b/src/model/Position.ts @@ -0,0 +1,10 @@ +'use strict'; + + +export default class Position { + constructor(public x: number, public y: number) {} + + asString(): string { + return `${this.x},${this.y}`; + } +} |