bullets now respawn (bit jittery)
This commit is contained in:
13
web/game.js
13
web/game.js
@@ -83,10 +83,10 @@ let playerSpeed = 3;
|
||||
// let squareY = 100;
|
||||
// const squareSize = 100;
|
||||
|
||||
let shotSpeed = 2;
|
||||
let shotSpeed = 5;
|
||||
let projectile;
|
||||
let projSize = 5;
|
||||
let shot = false;
|
||||
let shot;
|
||||
|
||||
// the function setup() is called once when the page is loaded
|
||||
function setup() {
|
||||
@@ -142,7 +142,7 @@ async function Movementloop() {
|
||||
|
||||
function shoot(directionX, directionY) {
|
||||
shot = true;
|
||||
|
||||
|
||||
if (!projectile) {
|
||||
// Set the initial position of the projectile to the player's position
|
||||
projectile = createVector(500, 100);
|
||||
@@ -159,9 +159,9 @@ function shoot(directionX, directionY) {
|
||||
direction.mult(shotSpeed);
|
||||
projectile.add(direction);
|
||||
|
||||
if (projectile.dist(target) >= 1) {
|
||||
if (projectile.dist(target) <= radius) {
|
||||
shot = false;
|
||||
// projectile = null;
|
||||
projectile = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,5 +184,8 @@ function draw() {
|
||||
|
||||
if (shot == false) {
|
||||
shoot(playerPosX, playerPosY);
|
||||
} else {
|
||||
shot = false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user