sam
2023-12-15 11:15:24 +01:00

View File

@@ -21,6 +21,7 @@ let isDead = false;
let bossPosX = width / 2; let bossPosX = width / 2;
let bossPosY = 100; let bossPosY = 100;
let shotSpeed = 12; let shotSpeed = 12;
let shotSpeedAdj;
let projectile; let projectile;
let projSize = 5; let projSize = 5;
let shot = false; let shot = false;
@@ -58,6 +59,12 @@ let nextWave = [];
let iIndex = 0; let iIndex = 0;
let bulletAmount = 5; let bulletAmount = 5;
let phase1 = false;
let phase2 = false;
let phase3 = false;
let phase4 = false;
let phase5 = false;
//let myBullet = new bullet(); //let myBullet = new bullet();
// the function setup() is called once when the page is loaded // the function setup() is called once when the page is loaded
function setup() { function setup() {
@@ -262,7 +269,10 @@ async function randPatern() {
chosen = false; chosen = false;
} }
if (patern == 5) { if (patern == 5) {
await wait(30000); if (phase1 == true) {
nextWave = random([1, 2, 3, 4]);
}
await wait(3000);
chosen = false; chosen = false;
} }
@@ -278,8 +288,10 @@ function randomAttackPattern() {
function phase() { function phase() {
switch (true) { switch (true) {
case (time < 10): case (time < 20):
paternArray = [1] phase1 = true;
paternArray = [5];
shotSpeedAdj = 3;
push(); push();
fill(255, 0, 255); fill(255, 0, 255);
textSize(10); textSize(10);
@@ -288,7 +300,10 @@ function phase() {
pop(); pop();
break; break;
case (time < 60): case (time < 60):
paternArray = [2, 5] shotSpeedAdj = 5;
paternArray = [5];
phase1 = false;
phase2 = true;
push(); push();
fill(255, 0, 255); fill(255, 0, 255);
textSize(10); textSize(10);
@@ -297,7 +312,9 @@ function phase() {
pop(); pop();
break; break;
case (time < 90): case (time < 90):
paternArray = [3, 4] phase2 = false;
phase3 = true;
paternArray = [2];
push(); push();
fill(255, 0, 255); fill(255, 0, 255);
textSize(10); textSize(10);
@@ -305,9 +322,10 @@ function phase() {
text("phase 3", 10, 50); text("phase 3", 10, 50);
pop(); pop();
break; break;
case (time >= 90): case (time < 120):
finalPhase = true; phase3 = false;
paternArray = [1, 2, 3, 4, 5] phase4 = true;
paternArray = [3, 4];
push(); push();
fill(255, 0, 255); fill(255, 0, 255);
textSize(10); textSize(10);
@@ -315,6 +333,18 @@ function phase() {
text("phase 4", 10, 50); text("phase 4", 10, 50);
pop(); pop();
break; 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,14 +428,16 @@ function spawnRandomBullet() {
angle = 0; angle = 0;
} }
if (patern == 5) { if (patern == 5) {
if (phase1 == false) {
nextWave = random([1, 2, 3, 4]); nextWave = random([1, 2, 3, 4]);
bulletAmount = 15; bulletAmount = 10;
}
if (nextWave == 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;
shotPosY = height; 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) { if (nextWave == 2) {
@@ -413,7 +445,7 @@ function spawnRandomBullet() {
let shotWidth = random(0, width); let shotWidth = random(0, width);
shotPosX = shotWidth; shotPosX = shotWidth;
shotPosY = 0; 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) { if (nextWave == 3) {
@@ -421,7 +453,7 @@ function spawnRandomBullet() {
let shotHeight = random(0, width); let shotHeight = random(0, width);
shotPosX = 0; shotPosX = 0;
shotPosY = shotHeight; 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) { if (nextWave == 4) {
@@ -429,15 +461,12 @@ function spawnRandomBullet() {
let shotHeight = random(0, width); let shotHeight = random(0, width);
shotPosX = width; shotPosX = width;
shotPosY = shotHeight; 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));
} }
} }
} else { } else {
bulletAmount = 5; bulletAmount = 5;
if (finalPhase == true) {
bulletAmount = 10;
}
} }
} }