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