added nextwave variable

This commit is contained in:
Mees Roelofsz
2023-12-13 12:51:49 +01:00
parent b3b5c54e4f
commit 0a586aa9b0

View File

@@ -48,6 +48,7 @@ let y5;
let homescreenOn = true; let homescreenOn = true;
let chosen = false; let chosen = false;
let finalPhase = false; let finalPhase = false;
let nextWave = [];
let bulletAmount = 5; let bulletAmount = 5;
//let myBullet = new bullet(); //let myBullet = new bullet();
@@ -316,9 +317,9 @@ function spawnRandomBullet() {
angle = 0; angle = 0;
} }
if (patern == 5) { if (patern == 5) {
let nextAttack = random([1, 2, 3, 4]); nextWave = random([1, 2, 3, 4]);
bulletAmount = 15; bulletAmount = 15;
if (nextAttack == 1) { if (nextWave == 1) {
for (let i = 0; i < random(8, 15); i++) { for (let i = 0; i < random(8, 15); i++) {
let shotWidth = random(0, width); let shotWidth = random(0, width);
shotPosX = shotWidth; shotPosX = shotWidth;
@@ -326,7 +327,7 @@ function spawnRandomBullet() {
bullets.push(new bullet(shotWidth, 0, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); bullets.push(new bullet(shotWidth, 0, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle));
} }
} }
if (nextAttack == 2) { if (nextWave == 2) {
for (let i = 0; i < random(8, 10); i++) { for (let i = 0; i < random(8, 10); i++) {
let shotWidth = random(0, width); let shotWidth = random(0, width);
shotPosX = shotWidth; shotPosX = shotWidth;
@@ -334,7 +335,7 @@ function spawnRandomBullet() {
bullets.push(new bullet(shotWidth, height, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); bullets.push(new bullet(shotWidth, height, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle));
} }
} }
if (nextAttack == 3) { if (nextWave == 3) {
for (let i = 0; i < random(8, 10); i++) { for (let i = 0; i < random(8, 10); i++) {
let shotHeight = random(0, width); let shotHeight = random(0, width);
shotPosX = 0; shotPosX = 0;
@@ -342,7 +343,7 @@ function spawnRandomBullet() {
bullets.push(new bullet(width, shotHeight, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); bullets.push(new bullet(width, shotHeight, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle));
} }
} }
if (nextAttack == 4) { if (nextWave == 4) {
for (let i = 0; i < random(8, 10); i++) { for (let i = 0; i < random(8, 10); i++) {
let shotHeight = random(0, width); let shotHeight = random(0, width);
shotPosX = width; shotPosX = width;