added former and current position

This commit is contained in:
Mees Roelofsz
2023-11-25 20:07:16 +01:00
parent 6fb6bc6aaf
commit 8afd36ba77

View File

@@ -155,8 +155,9 @@ function shoot(directionX, directionY) {
circle(projectile.x, projectile.y, projSize); circle(projectile.x, projectile.y, projSize);
// Move the projectile towards the movable circle // Move the projectile towards the movable circle
let target = createVector(Xbuffer, Ybuffer); let targetFormer = createVector(Xbuffer, Ybuffer);
let direction = target.copy().sub(projectile); let target = createVector(directionX, directionY);
let direction = targetFormer.copy().sub(projectile);
direction.normalize(); direction.normalize();
direction.mult(shotSpeed); direction.mult(shotSpeed);
projectile.add(direction); projectile.add(direction);