diff --git a/web/game.js b/web/game.js index e09b8d8..765bfd5 100644 --- a/web/game.js +++ b/web/game.js @@ -58,6 +58,12 @@ let nextWave = []; let iIndex = 0; let bulletAmount = 5; + +let phase1 = false; +let phase2 = false; +let phase3 = false; +let phase4 = false; +let phase5 = false; //let myBullet = new bullet(); // the function setup() is called once when the page is loaded function setup() { @@ -262,7 +268,10 @@ async function randPatern() { chosen = false; } if (patern == 5) { - await wait(30000); + if (phase1 == true) { + nextWave = random([1, 2, 3, 4]); + } + await wait(3000); chosen = false; } @@ -278,8 +287,9 @@ function randomAttackPattern() { function phase() { switch (true) { - case (time < 10): - paternArray = [1] + case (time < 20): + phase1 = true; + paternArray = [1,5]; push(); fill(255, 0, 255); textSize(10); @@ -288,7 +298,9 @@ function phase() { pop(); break; case (time < 60): - paternArray = [2, 5] + paternArray = [5]; + phase1 = false; + phase2 = true; push(); fill(255, 0, 255); textSize(10); @@ -297,7 +309,9 @@ function phase() { pop(); break; case (time < 90): - paternArray = [3, 4] + phase2 = false; + phase3 = true; + paternArray = [2]; push(); fill(255, 0, 255); textSize(10); @@ -305,9 +319,10 @@ function phase() { text("phase 3", 10, 50); pop(); break; - case (time >= 90): - finalPhase = true; - paternArray = [1, 2, 3, 4, 5] + case (time < 120): + phase3 = false; + phase4 = true; + paternArray = [3, 4]; push(); fill(255, 0, 255); textSize(10); @@ -315,6 +330,18 @@ function phase() { text("phase 4", 10, 50); pop(); break; + case (time >= 120): + phase4 = false; + phase5 = false; + finalPhase = true; + paternArray = [1, 2, 3, 4, 5]; + push(); + fill(255, 0, 255); + textSize(10); + textAlign(LEFT); + text("phase 5", 10, 50); + pop(); + break; } } @@ -398,8 +425,10 @@ function spawnRandomBullet() { angle = 0; } if (patern == 5) { - nextWave = random([1, 2, 3, 4]); - bulletAmount = 15; + if (phase1 == false) { + nextWave = random([1, 2, 3, 4]); + bulletAmount = 10; + } if (nextWave == 1) { for (let i = 0; i < random(8, 15); i++) { let shotWidth = random(0, width); @@ -435,9 +464,6 @@ function spawnRandomBullet() { } else { bulletAmount = 5; - if (finalPhase == true) { - bulletAmount = 10; - } } }