export interface Velocity { x: number; y: number; } export class Position { constructor(public x: number, public y: number) {} clone(): Position { return new Position(this.x, this.y); } moveX(x: number): Position { this.x = x; return this; } moveY(y: number): Position { this.y = y; return this; } move(x: number, y: number): Position { this.x = x; this.y = y; return this; } addX(x: number): Position { return this.add(x, 0); } addY(y: number): Position { return this.add(0, y); } add(x: number, y: number): Position { this.x += x; this.y += y; return this; } } export interface Size { width: number; height: number; } export interface Element { size: Size; pos: Position; instance: HTMLElement; update(): void; }