summaryrefslogtreecommitdiffstats
path: root/src/model/Position.ts
blob: ebb38205a52cfaddb7b80180f687bb3931107fac (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
'use strict';


import Direction from './Direction';


export default class Position {
        constructor(public x: number, public y: number) {}

        translate(dir: Direction, amount: number): Position {
		var p = new Position(this.x, this.y);

		switch (dir) {
		case Direction.North:
			p.y -= amount;
			break;

		case Direction.East:
			p.x += amount;
			break;

		case Direction.South:
			p.y += amount;
			break;

		case Direction.West:
			p.x -= amount;
		}

		return p;
	}
}