summaryrefslogtreecommitdiffstats
path: root/src/model/data
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-11-08 22:03:08 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-11-08 22:25:53 +0100
commit5eae6f29a80cd47e268cb6eaefa96a0ab0a63e54 (patch)
tree2631f7b3a9d55adc7d07408b30aecb7b714c25be /src/model/data
parent40339947d1a2407a6be95fad58215cdaf7d4c2c9 (diff)
downloadrpgedit-5eae6f29a80cd47e268cb6eaefa96a0ab0a63e54.tar
rpgedit-5eae6f29a80cd47e268cb6eaefa96a0ab0a63e54.zip
Implement more flexible handling of entities and collidables
Diffstat (limited to 'src/model/data')
-rw-r--r--src/model/data/collision.ts6
-rw-r--r--src/model/data/entity.ts19
-rw-r--r--src/model/data/map.ts11
3 files changed, 28 insertions, 8 deletions
diff --git a/src/model/data/collision.ts b/src/model/data/collision.ts
new file mode 100644
index 0000000..5008fa3
--- /dev/null
+++ b/src/model/data/collision.ts
@@ -0,0 +1,6 @@
+export interface CollisionPolygon {
+ readonly type: 'polygon';
+ readonly vertices: Array<[number, number]>;
+}
+
+export type Collision = CollisionPolygon;
diff --git a/src/model/data/entity.ts b/src/model/data/entity.ts
new file mode 100644
index 0000000..3474a38
--- /dev/null
+++ b/src/model/data/entity.ts
@@ -0,0 +1,19 @@
+import { Collision } from './collision';
+
+export interface EntityDataInput {
+ readonly sprite: string;
+ readonly anchor?: [number, number];
+ readonly collision?: Collision[];
+}
+
+export class EntityData {
+ public readonly sprite: string;
+ public readonly anchor: [number, number];
+ public readonly collision: Collision[];
+
+ constructor(input: EntityDataInput) {
+ this.sprite = input.sprite;
+ this.anchor = input.anchor || [0.5, 0.5];
+ this.collision = input.collision || [];
+ }
+}
diff --git a/src/model/data/map.ts b/src/model/data/map.ts
index 4d9ecda..b36f6b5 100644
--- a/src/model/data/map.ts
+++ b/src/model/data/map.ts
@@ -1,11 +1,6 @@
-export interface CollisionPolygon {
- readonly type: 'polygon';
- readonly vertices: Array<[number, number]>;
-}
-
-export type Collision = CollisionPolygon;
+import { Collision } from './collision';
-export interface Input {
+export interface MapDataInput {
readonly tiles: string[];
readonly layers: number[][][];
readonly collision: Collision[];
@@ -19,7 +14,7 @@ export class MapData {
public readonly width: number;
public readonly height: number;
- constructor(data: Input) {
+ constructor(data: MapDataInput) {
this.tiles = data.tiles;
this.layers = data.layers;
this.collision = data.collision;