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;
|
// let squareY = 100;
|
||||||
// const squareSize = 100;
|
// const squareSize = 100;
|
||||||
|
|
||||||
let shotSpeed = 2;
|
let shotSpeed = 5;
|
||||||
let projectile;
|
let projectile;
|
||||||
let projSize = 5;
|
let projSize = 5;
|
||||||
let shot = false;
|
let shot;
|
||||||
|
|
||||||
// the function setup() is called once when the page is loaded
|
// the function setup() is called once when the page is loaded
|
||||||
function setup() {
|
function setup() {
|
||||||
@@ -142,7 +142,7 @@ async function Movementloop() {
|
|||||||
|
|
||||||
function shoot(directionX, directionY) {
|
function shoot(directionX, directionY) {
|
||||||
shot = true;
|
shot = true;
|
||||||
|
|
||||||
if (!projectile) {
|
if (!projectile) {
|
||||||
// Set the initial position of the projectile to the player's position
|
// Set the initial position of the projectile to the player's position
|
||||||
projectile = createVector(500, 100);
|
projectile = createVector(500, 100);
|
||||||
@@ -159,9 +159,9 @@ function shoot(directionX, directionY) {
|
|||||||
direction.mult(shotSpeed);
|
direction.mult(shotSpeed);
|
||||||
projectile.add(direction);
|
projectile.add(direction);
|
||||||
|
|
||||||
if (projectile.dist(target) >= 1) {
|
if (projectile.dist(target) <= radius) {
|
||||||
shot = false;
|
shot = false;
|
||||||
// projectile = null;
|
projectile = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,5 +184,8 @@ function draw() {
|
|||||||
|
|
||||||
if (shot == false) {
|
if (shot == false) {
|
||||||
shoot(playerPosX, playerPosY);
|
shoot(playerPosX, playerPosY);
|
||||||
|
} else {
|
||||||
|
shot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user