summaryrefslogtreecommitdiffstats
path: root/src/model/data/entity.ts
blob: f52c13063f619caf6e864335dd2f149b2c98d787 (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
import { Collision } from './collision';

export interface EntityAnimation {
	readonly sequence: ReadonlyArray<[number, number]>;
}

export interface EntityDataInput {
	readonly sprite: string;
	readonly anchor?: [number, number];
	readonly collision?: Collision[];
	readonly frames?: number;
	readonly animation?: EntityAnimation;
}

export class EntityData {
	public readonly sprite: string;
	public readonly anchor: [number, number];
	public readonly collision: Collision[];
	public readonly frames: number;
	public readonly animation?: EntityAnimation;

	constructor(input: EntityDataInput) {
		this.sprite = input.sprite;
		this.anchor = input.anchor || [0.5, 0.5];
		this.collision = input.collision || [];
		this.frames = input.frames || 1;
		this.animation = input.animation;
	}
}