temporarily commented object collision
This commit is contained in:
29
web/game.js
29
web/game.js
@@ -79,12 +79,13 @@ let playerPosY = 300;
|
|||||||
let playerSpeed = 3;
|
let playerSpeed = 3;
|
||||||
|
|
||||||
|
|
||||||
let squareX = 100;
|
// let squareX = 100;
|
||||||
let squareY = 100;
|
// let squareY = 100;
|
||||||
const squareSize = 100;
|
// const squareSize = 100;
|
||||||
|
|
||||||
let shotSpeed = 2;
|
let shotSpeed = 2;
|
||||||
let projectile;
|
let projectile;
|
||||||
|
let projSize = 5;
|
||||||
let shot = false;
|
let shot = false;
|
||||||
|
|
||||||
// the function setup() is called once when the page is loaded
|
// the function setup() is called once when the page is loaded
|
||||||
@@ -127,17 +128,17 @@ async function Movementloop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function object_collision() {
|
// function object_collision() {
|
||||||
var squareCenterX = squareX + squareSize / 2;
|
// var squareCenterX = squareX + squareSize / 2;
|
||||||
var squareCenterY = squareY + squareSize / 2;
|
// var squareCenterY = squareY + squareSize / 2;
|
||||||
|
|
||||||
var distance = dist(playerPosX, playerPosY, squareCenterX, squareCenterY);
|
// var distance = dist(playerPosX, playerPosY, squareCenterX, squareCenterY);
|
||||||
|
|
||||||
if (distance < squareSize / 2 + radius) {
|
// if (distance < squareSize / 2 + radius) {
|
||||||
squareX = random(0, width - squareSize);
|
// squareX = random(0, width - squareSize);
|
||||||
squareY = random(0, height - squareSize);
|
// squareY = random(0, height - squareSize);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function shoot(directionX, directionY) {
|
function shoot(directionX, directionY) {
|
||||||
shot = true;
|
shot = true;
|
||||||
@@ -150,7 +151,7 @@ function shoot(directionX, directionY) {
|
|||||||
|
|
||||||
// Draw the small circle (projectile)
|
// Draw the small circle (projectile)
|
||||||
fill(255, 0, 0);
|
fill(255, 0, 0);
|
||||||
circle(projectile.x, projectile.y, 5);
|
circle(projectile.x, projectile.y, projSize);
|
||||||
|
|
||||||
// Move the projectile towards the movable circle
|
// Move the projectile towards the movable circle
|
||||||
let target = createVector(directionX, directionY);
|
let target = createVector(directionX, directionY);
|
||||||
@@ -167,7 +168,7 @@ function draw() {
|
|||||||
|
|
||||||
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
circle(constrain(playerPosX, 0 + radius, width - radius), constrain(playerPosY, 0 + radius, height - radius), playerSize);
|
||||||
// square(squareX,squareY,squareSize);
|
// square(squareX,squareY,squareSize);
|
||||||
object_collision();
|
// object_collision();
|
||||||
|
|
||||||
shoot(playerPosX, playerPosY);
|
shoot(playerPosX, playerPosY);
|
||||||
}
|
}
|
Reference in New Issue
Block a user