added border and player collision to projectiles
This commit is contained in:
11
web/game.js
11
web/game.js
@@ -109,15 +109,13 @@ function shoot(directionX, directionY) {
|
||||
// Move the projectile towards the movable circle
|
||||
projectile.add(p5.Vector.mult(direction, shotSpeed));
|
||||
|
||||
if (dist(projectile.x, projectile.y, targetX, targetY) <= radius) {
|
||||
if (playerPosX == targetX && playerPosY == targetY) {
|
||||
if (dist(projectile.x, projectile.y, directionX, directionY) <= radius) {
|
||||
projectile = null;
|
||||
shot = false;
|
||||
}
|
||||
// if (projectile.x < 0 || projectile.x > width || projectile.y < 0 || projectile.y > height) {
|
||||
// projectile = null;
|
||||
// shot = false;
|
||||
// }
|
||||
else if (projectile.x < 0 || projectile.x > width || projectile.y < 0 || projectile.y > height) {
|
||||
projectile = null;
|
||||
shot = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +136,7 @@ function draw() {
|
||||
score();
|
||||
text(time, 10, 20);
|
||||
|
||||
|
||||
// square(squareX,squareY,squareSize);
|
||||
// object_collision();
|
||||
|
||||
|
Reference in New Issue
Block a user