From e5cf614a83438d4a09cbe2bbcf831a98f999ab1d Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Fri, 15 Dec 2023 09:44:57 +0100 Subject: [PATCH 1/2] added singular wave to phase 1 --- web/game.js | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) 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; - } } } From 9083204a3abd786e8cdaba4a8d6c7869d8ac7b50 Mon Sep 17 00:00:00 2001 From: Mees Roelofsz Date: Fri, 15 Dec 2023 10:36:08 +0100 Subject: [PATCH 2/2] added changing projectile speeds --- web/game.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/web/game.js b/web/game.js index 765bfd5..1ed35f1 100644 --- a/web/game.js +++ b/web/game.js @@ -21,6 +21,7 @@ let isDead = false; let bossPosX = width / 2; let bossPosY = 100; let shotSpeed = 12; +let shotSpeedAdj; let projectile; let projSize = 5; let shot = false; @@ -289,7 +290,8 @@ function phase() { switch (true) { case (time < 20): phase1 = true; - paternArray = [1,5]; + paternArray = [5]; + shotSpeedAdj = 3; push(); fill(255, 0, 255); textSize(10); @@ -298,6 +300,7 @@ function phase() { pop(); break; case (time < 60): + shotSpeedAdj = 5; paternArray = [5]; phase1 = false; phase2 = true; @@ -434,7 +437,7 @@ function spawnRandomBullet() { let shotWidth = random(0, width); shotPosX = shotWidth; shotPosY = height; - bullets.push(new bullet(shotWidth, 0, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); + bullets.push(new bullet(shotWidth, 0, radius, shotSpeed / shotSpeedAdj, shotPosX, shotPosY, hasMoved, angle)); } } if (nextWave == 2) { @@ -442,7 +445,7 @@ function spawnRandomBullet() { let shotWidth = random(0, width); shotPosX = shotWidth; shotPosY = 0; - bullets.push(new bullet(shotWidth, height, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); + bullets.push(new bullet(shotWidth, height, radius, shotSpeed / shotSpeedAdj, shotPosX, shotPosY, hasMoved, angle)); } } if (nextWave == 3) { @@ -450,7 +453,7 @@ function spawnRandomBullet() { let shotHeight = random(0, width); shotPosX = 0; shotPosY = shotHeight; - bullets.push(new bullet(width, shotHeight, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); + bullets.push(new bullet(width, shotHeight, radius, shotSpeed / shotSpeedAdj, shotPosX, shotPosY, hasMoved, angle)); } } if (nextWave == 4) { @@ -458,7 +461,7 @@ function spawnRandomBullet() { let shotHeight = random(0, width); shotPosX = width; shotPosY = shotHeight; - bullets.push(new bullet(0, shotHeight, radius, shotSpeed / 5, shotPosX, shotPosY, hasMoved, angle)); + bullets.push(new bullet(0, shotHeight, radius, shotSpeed / shotSpeedAdj, shotPosX, shotPosY, hasMoved, angle)); } }