mirror of
https://github.com/Sheldan/canvas.git
synced 2026-04-21 21:41:27 +00:00
survivors: reducing jumpiness of homing projectiles re-directing by limiting it to a certain angle
adding rad degree conversion utils checking world border for projectiles
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type {Placeable} from "./interfaces.ts";
|
||||
|
||||
export class Vector {
|
||||
|
||||
constructor(private _x: number, private _y: number) {
|
||||
@@ -44,6 +46,13 @@ export class Vector {
|
||||
return this.multiply(-1)
|
||||
}
|
||||
|
||||
dotProduct(vector: Vector): number {
|
||||
return this._x * vector._x + this._y * vector._y;
|
||||
}
|
||||
|
||||
angleTo(vector: Vector): number {
|
||||
return Math.acos(this.dotProduct(vector))
|
||||
}
|
||||
|
||||
get x(): number {
|
||||
return this._x;
|
||||
@@ -87,4 +96,25 @@ export class Cooldown {
|
||||
resetCooldown() {
|
||||
this._currentValue = this._totalValue;
|
||||
}
|
||||
}
|
||||
|
||||
export class Point implements Placeable {
|
||||
|
||||
private position: Vector;
|
||||
|
||||
|
||||
constructor(position: Vector) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
getPosition(): Vector {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
getSize() {
|
||||
}
|
||||
|
||||
move(any?: any) {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user