added different way of angling bullets(no succes)

This commit is contained in:
Mees Roelofsz
2023-11-30 21:37:06 +01:00
parent f81bdf9ef4
commit 68d9ecba9e

View File

@@ -36,6 +36,7 @@ let framerate = 120;
let hasMoved = false;
let time = 0;
let shotPoint = 0;
let angle = 0;
//let myBullet = new bullet();
// the function setup() is called once when the page is loaded
@@ -70,16 +71,13 @@ function life() {
time = 0;
bounceX = bossPosX;
bounceY = bossPosY;
initialPlayerPosX = playerPosX;
initialPlayerPosY = playerPosY;
hasMoved = false;
bullets = [];
shot = false;
}
}
function movementCheck() {
if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) {
if (playerPosX != initialPlayerPosX && playerPosY != initialPlayerPosY) {
hasMoved = true;
}
}
@@ -206,22 +204,22 @@ function spawnRandomBullet(){
nextAttack = random([1, 2, 3, 4]);
text(nextAttack, 30, 50);
if (nextAttack == 1) {
shotPosX = 510;
shotPosX = 500;
shotPosY = 100;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
}
if (nextAttack == 2) {
shotPosX = random(0, 1000);
shotPosY = 610;
shotPosY = 600;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
}
if (nextAttack == 3) {
shotPosX = -10;
shotPosX = 0;
shotPosY = random(0, 600);
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
}
if (nextAttack == 4) {
shotPosX = 1010;
shotPosX = 1000;
shotPosY = random(0, 600);
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
@@ -235,11 +233,12 @@ function spawnRandomBullet(){
if (patern == 3) {
shotPosX = 500;
shotPosY = 100;
shotPoint = 0;
for (let i = 0; i < 50; i++) {
shotPoint = shotPoint + 50;
bullets.push(new bullet(0, shotPoint, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
angle = 0;
// changing the angle of the bullets
for (let i = 0; i < 180; i++) {
let angleChange = map(i, 0, 50, 0, 360); // Example: linear change
bullets.push(new bullet(0, angle + angleChange, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
// angle += 360 / 50;
}
}