initial implementation of arkanoid.ts

This commit is contained in:
2021-09-21 20:13:51 +02:00
commit 814c564a85
15 changed files with 20784 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
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;
}