sam
2023-12-05 14:26:54 +01:00

View File

@@ -26,10 +26,6 @@ let initialPlayerPosX = playerPosX;
let initialPlayerPosY = playerPosY; let initialPlayerPosY = playerPosY;
let nextAttack; let nextAttack;
// let bounceX = bossPosX;
// let bounceY = bossPosY;
// let predictiveBounceX;
// let predictiveBounceY;
let bullets = []; let bullets = [];
let direction; let direction;
let framerate = 120; let framerate = 120;
@@ -38,7 +34,7 @@ let time = 0;
let shotPoint = 0; let shotPoint = 0;
let angle = 0; let angle = 0;
let patern = 2; let patern;
let suroundX = 300; let suroundX = 300;
let suroundY = 300; let suroundY = 300;
let x2; let x2;
@@ -50,6 +46,8 @@ let y4;
let x5; let x5;
let y5; let y5;
let bulletAmount = 10;
//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
@@ -149,8 +147,10 @@ function draw() {
// draw boss // draw boss
fill(255, 165, 0) fill(255, 165, 0)
circle(x2, y2, 50); circle(x2, y2, 50);
if (hasMoved == true) {
score(); score();
}
textAlign(LEFT); textAlign(LEFT);
text(int(time), 10, 20); text(int(time), 10, 20);
@@ -193,19 +193,18 @@ function draw() {
function randomAttackPattern() { function randomAttackPattern() {
if (shot == false || hit == true) { if (shot == false || hit == true) {
for (i = 0; i < bulletAmount; i++) {
spawnRandomBullet() spawnRandomBullet()
spawnRandomBullet() }
spawnRandomBullet()
spawnRandomBullet()
} }
} }
function spawnRandomBullet() { function spawnRandomBullet() {
//patern = random([2]); patern = random([1,2]);
if (patern == 1) { if (patern == 1) {
nextAttack = random([1, 2, 3, 4]); nextAttack = random([1, 2, 3, 4, 5]);
text(nextAttack, 30, 50); //text(nextAttack, 30, 50);
if (nextAttack == 1) { if (nextAttack == 1) {
shotPosX = bossPosX; shotPosX = bossPosX;
shotPosY = bossPosY; shotPosY = bossPosY;
@@ -213,19 +212,24 @@ function spawnRandomBullet() {
} }
if (nextAttack == 2) { if (nextAttack == 2) {
shotPosX = random(0, 1000); shotPosX = random(0, 1000);
shotPosY = 610; shotPosY = 600;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
} }
if (nextAttack == 3) { if (nextAttack == 3) {
shotPosX = -10; shotPosX = 10;
shotPosY = random(0, 600); shotPosY = random(0, 600);
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
} }
if (nextAttack == 4) { if (nextAttack == 4) {
shotPosX = 1010; shotPosX = 1000;
shotPosY = random(0, 600); shotPosY = random(0, 600);
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0)); bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
} }
if (nextAttack == 5) {
shotPosX = random(0, 1000);
shotPosY = 0;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
}
} }
if (patern == 2) { if (patern == 2) {
let suroundChoice = random([1, 2, 3, 4]); let suroundChoice = random([1, 2, 3, 4]);