fixed radius
This commit is contained in:
@@ -9,9 +9,9 @@ class bullet {
|
||||
this.speed = speed;
|
||||
|
||||
// Set the initial position of the projectile to the player's position
|
||||
let projectile = createVector(shotPosX, shotPosY);
|
||||
x = directionX;
|
||||
y = directionY;
|
||||
let projectile = createVector(this.x, this.y);
|
||||
this.x = directionX;
|
||||
this.y = directionY;
|
||||
|
||||
// Calculate the initial direction
|
||||
direction = createVector(targetX - projectile.x, targetY - projectile.y);
|
||||
@@ -27,7 +27,7 @@ draw() {
|
||||
fill(255, 0, 0);
|
||||
circle(500, 500, 5);
|
||||
projectile.add(p5.Vector.mult(direction, shotSpeed));
|
||||
if (dist(projectile.x, projectile.y, directionX, directionY) <= radius) {
|
||||
if (dist(projectile.x, projectile.y, directionX, directionY) <= this.radius) {
|
||||
hit = true;
|
||||
}
|
||||
else if (projectile.x < 0 - 10 || projectile.x > width + 10 || projectile.y < 0 - 10 || projectile.y > height + 10) {
|
||||
|
Reference in New Issue
Block a user