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