survivors: adding first version

This commit is contained in:
Sheldan
2025-08-21 13:16:29 +02:00
parent 8a6e3b86df
commit 9b5ab25c4d
22 changed files with 2003 additions and 9 deletions

View File

@@ -0,0 +1,18 @@
import {Vector} from "./base.ts";
export function drawDot(position: Vector, size: number, color: string, ctx: CanvasRenderingContext2D) {
ctx.beginPath();
ctx.fillStyle = color;
ctx.arc(position.x, position.y, size, 0, 2 * Math.PI);
ctx.fill();
}
export function moveInDirectionOf(position: Vector, target: Vector, speedFactor): Vector {
let playerVector = Vector.createVector(target, position);
let direction = playerVector.normalize()
return position.add(direction.multiply(speedFactor))
}
export function straightMove(position: Vector, speed: Vector): Vector {
return position.add(speed)
}