added bullet waves

This commit is contained in:
Mees Roelofsz
2023-12-06 14:41:39 +01:00
parent ada6119127
commit e939ad1797

View File

@@ -25,7 +25,6 @@ let shotPosY;
let initialPlayerPosX = playerPosX;
let initialPlayerPosY = playerPosY;
let nextAttack;
let bullets = [];
let direction;
let framerate = 120;
@@ -48,7 +47,7 @@ let y5;
let homescreenOn = false;
let chosen = false;
let bulletAmount = 10;
let bulletAmount = 20;
//let myBullet = new bullet();
// the function setup() is called once when the page is loaded
function setup() {
@@ -228,7 +227,7 @@ function draw() {
}
async function randPatern () {
patern = random([1,2]);
patern = random([5]);
chosen = true;
if (patern == 1) {
await wait(3000);
@@ -238,6 +237,10 @@ async function randPatern () {
await wait(5000);
chosen = false;
}
if (patern == 5) {
await wait(30000);
chosen = false;
}
}
@@ -255,7 +258,7 @@ function spawnRandomBullet() {
}
if (patern == 1) {
nextAttack = random([1, 2, 3, 4, 5]);
let nextAttack = random([1, 2, 3, 4, 5]);
//text(nextAttack, 30, 50);
if (nextAttack == 1) {
shotPosX = bossPosX;
@@ -328,6 +331,42 @@ function spawnRandomBullet() {
}
angle = 0;
}
if (patern == 5) {
let nextAttack = random([1, 2, 3]);
if (nextAttack == 1) {
for (let i = 0; i < random(3, 10); i++) {
let shotWidth = random(0, width);
shotPosX = shotWidth
shotPosY = height;
bullets.push(new bullet(shotWidth, 0, radius, shotSpeed/4, shotPosX, shotPosY, hasMoved, angle));
}
}
if (nextAttack == 2) {
for (let i = 0; i < random(3, 10); i++) {
let shotWidth = random(0, width);
shotPosX = shotWidth
shotPosY = 0;
bullets.push(new bullet(shotWidth, height, radius, shotSpeed/4, shotPosX, shotPosY, hasMoved, angle));
}
}
if (nextAttack == 3) {
for (let i = 0; i < random(3, 10); i++) {
let shotHeight = random(0, width);
shotPosX = 0
shotPosY = shotHeight;
bullets.push(new bullet(width, shotHeight, radius, shotSpeed/4, shotPosX, shotPosY, hasMoved, angle));
}
}
if (nextAttack == 3) {
for (let i = 0; i < random(3, 10); i++) {
let shotHeight = random(0, width);
shotPosX = width
shotPosY = shotHeight;
bullets.push(new bullet(0, shotHeight, radius, shotSpeed/4, shotPosX, shotPosY, hasMoved, angle));
}
}
}
}