bullets now respawn (bit jittery)

This commit is contained in:
Mees Roelofsz
2023-11-25 18:59:29 +01:00
parent 3352ed4dc5
commit f8fa2747c7

View File

@@ -83,10 +83,10 @@ let playerSpeed = 3;
// let squareY = 100; // let squareY = 100;
// const squareSize = 100; // const squareSize = 100;
let shotSpeed = 2; let shotSpeed = 5;
let projectile; let projectile;
let projSize = 5; let projSize = 5;
let shot = false; let shot;
// the function setup() is called once when the page is loaded // the function setup() is called once when the page is loaded
function setup() { function setup() {
@@ -159,9 +159,9 @@ function shoot(directionX, directionY) {
direction.mult(shotSpeed); direction.mult(shotSpeed);
projectile.add(direction); projectile.add(direction);
if (projectile.dist(target) >= 1) { if (projectile.dist(target) <= radius) {
shot = false; shot = false;
// projectile = null; projectile = null;
} }
} }
@@ -184,5 +184,8 @@ function draw() {
if (shot == false) { if (shot == false) {
shoot(playerPosX, playerPosY); shoot(playerPosX, playerPosY);
} else {
shot = false;
} }
} }