added player radius for correct collision
This commit is contained in:
@@ -32,7 +32,7 @@ class bullet {
|
|||||||
pop();
|
pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
update(targetx, targety, hasMoved) {
|
update(targetx, targety, hasMoved, radius) {
|
||||||
// keeps the projetile updated so hit collision can be checked
|
// keeps the projetile updated so hit collision can be checked
|
||||||
this.targetx = targetx;
|
this.targetx = targetx;
|
||||||
this.targety = targety;
|
this.targety = targety;
|
||||||
@@ -43,7 +43,7 @@ class bullet {
|
|||||||
let shot = true;
|
let shot = true;
|
||||||
let travelled = false;
|
let travelled = false;
|
||||||
// check if the projectile has hit the player
|
// check if the projectile has hit the player
|
||||||
if (dist(this.projectile.x, this.projectile.y, this.targetx, this.targety) <= this.radius) {
|
if (dist(this.projectile.x, this.projectile.y, this.targetx, this.targety) <= this.radius + radius) {
|
||||||
hit = true;
|
hit = true;
|
||||||
shot = false;
|
shot = false;
|
||||||
// if the projectile has hit the player and the player has lives left, remove a life
|
// if the projectile has hit the player and the player has lives left, remove a life
|
||||||
|
Reference in New Issue
Block a user