summaryrefslogtreecommitdiffstats
path: root/src/model
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-01-07 11:22:59 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-01-07 11:22:59 +0100
commit584728a1293a5215baaca4e7de813b2a85b8253d (patch)
tree61fe7f216fa857d0a86d8ed28f3346d242f6b992 /src/model
parentb7fec57c0463e58f1ad8db126ff4879f59b057d0 (diff)
downloadrpgedit-584728a1293a5215baaca4e7de813b2a85b8253d.tar
rpgedit-584728a1293a5215baaca4e7de813b2a85b8253d.zip
Implement smooth transitions
Diffstat (limited to 'src/model')
-rw-r--r--src/model/EntityPosition.ts5
-rw-r--r--src/model/Position.ts26
-rw-r--r--src/model/Transition.ts8
3 files changed, 38 insertions, 1 deletions
diff --git a/src/model/EntityPosition.ts b/src/model/EntityPosition.ts
index 815eceb..28b3837 100644
--- a/src/model/EntityPosition.ts
+++ b/src/model/EntityPosition.ts
@@ -1,11 +1,14 @@
'use strict';
-import Direction from '../model/Direction';
+import Direction from './Direction';
import Entity from './Entity';
import Position from './Position';
+import Transition from './Transition';
export default class EntityPosition {
+ public transition: Transition = null;
+
constructor(public entity: Entity, public position: Position, public direction: Direction) {}
}
diff --git a/src/model/Position.ts b/src/model/Position.ts
index 1db37af..1f9b719 100644
--- a/src/model/Position.ts
+++ b/src/model/Position.ts
@@ -1,9 +1,35 @@
'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;
+ }
+
asString(): string {
return `${this.x},${this.y}`;
}
diff --git a/src/model/Transition.ts b/src/model/Transition.ts
new file mode 100644
index 0000000..0a3e69b
--- /dev/null
+++ b/src/model/Transition.ts
@@ -0,0 +1,8 @@
+'use strict';
+
+
+import Position from './Position';
+
+export default class Transition {
+ constructor(public start: number, public end: number, public orig: Position, public dest: Position) {}
+};