mirror of
https://github.com/Sheldan/canvas.git
synced 2026-04-15 12:10:20 +00:00
survivors: adding simple drops
moving size to world object adding dying for enemies and projectiles and theoretically for players adding pull range for player adding money stat display made pistol homing
This commit is contained in:
@@ -16,6 +16,10 @@ export class Vector {
|
||||
return Math.sqrt(this.x * this.x + this.y * this.y);
|
||||
}
|
||||
|
||||
clone() {
|
||||
return new Vector(this.x, this.y)
|
||||
}
|
||||
|
||||
distanceTo(point: Vector): number {
|
||||
return Math.sqrt(Math.pow(this.x - point.x, 2) + Math.pow(this.y - point.y, 2));
|
||||
}
|
||||
@@ -56,4 +60,31 @@ export class Vector {
|
||||
set y(value: number) {
|
||||
this._y = value;
|
||||
}
|
||||
}
|
||||
|
||||
export class Cooldown {
|
||||
private _currentValue;
|
||||
private _totalValue;
|
||||
|
||||
|
||||
constructor(totalValue) {
|
||||
this._totalValue = totalValue;
|
||||
this._currentValue = 0
|
||||
}
|
||||
|
||||
cooledDown(): boolean {
|
||||
return this.currentValue <= 0;
|
||||
}
|
||||
|
||||
get currentValue(): number {
|
||||
return this._currentValue;
|
||||
}
|
||||
|
||||
decreaseCooldown() {
|
||||
this._currentValue -= 1;
|
||||
}
|
||||
|
||||
resetCooldown() {
|
||||
this._currentValue = this._totalValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user