added phases
This commit is contained in:
67
web/game.js
67
web/game.js
@@ -34,6 +34,7 @@ let shotPoint = 0;
|
|||||||
let angle = 0;
|
let angle = 0;
|
||||||
|
|
||||||
let patern;
|
let patern;
|
||||||
|
let paternArray = [];
|
||||||
let suroundX = 300;
|
let suroundX = 300;
|
||||||
let suroundY = 300;
|
let suroundY = 300;
|
||||||
let x2;
|
let x2;
|
||||||
@@ -47,7 +48,7 @@ let y5;
|
|||||||
let homescreenOn = true;
|
let homescreenOn = true;
|
||||||
let chosen = false;
|
let chosen = false;
|
||||||
|
|
||||||
let bulletAmount = 20;
|
let bulletAmount = 5;
|
||||||
//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() {
|
||||||
@@ -144,6 +145,7 @@ async function Movementloop() {
|
|||||||
function draw() {
|
function draw() {
|
||||||
keyPressed();
|
keyPressed();
|
||||||
life();
|
life();
|
||||||
|
phase();
|
||||||
// draw background
|
// draw background
|
||||||
//myBullet.draw();
|
//myBullet.draw();
|
||||||
background(0, 0, 0, 100);
|
background(0, 0, 0, 100);
|
||||||
@@ -157,7 +159,7 @@ function draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function randPatern() {
|
async function randPatern() {
|
||||||
patern = random([5]);
|
patern = random(paternArray);
|
||||||
chosen = true;
|
chosen = true;
|
||||||
if (patern == 1) {
|
if (patern == 1) {
|
||||||
await wait(3000);
|
await wait(3000);
|
||||||
@@ -167,6 +169,14 @@ async function randPatern () {
|
|||||||
await wait(5000);
|
await wait(5000);
|
||||||
chosen = false;
|
chosen = false;
|
||||||
}
|
}
|
||||||
|
if (patern == 3) {
|
||||||
|
await wait(1000);
|
||||||
|
chosen = false;
|
||||||
|
}
|
||||||
|
if (patern == 4) {
|
||||||
|
await wait(1000);
|
||||||
|
chosen = false;
|
||||||
|
}
|
||||||
if (patern == 5) {
|
if (patern == 5) {
|
||||||
await wait(30000);
|
await wait(30000);
|
||||||
chosen = false;
|
chosen = false;
|
||||||
@@ -182,6 +192,47 @@ function randomAttackPattern() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function phase() {
|
||||||
|
switch (true) {
|
||||||
|
case (time < 10):
|
||||||
|
paternArray = [1]
|
||||||
|
push();
|
||||||
|
fill(255, 0, 255);
|
||||||
|
textSize(10);
|
||||||
|
textAlign(LEFT);
|
||||||
|
text("phase 1", 10, 50);
|
||||||
|
pop();
|
||||||
|
break;
|
||||||
|
case (time < 20):
|
||||||
|
paternArray = [2, 5]
|
||||||
|
push();
|
||||||
|
fill(255, 0, 255);
|
||||||
|
textSize(10);
|
||||||
|
textAlign(LEFT);
|
||||||
|
text("phase 2", 10, 50);
|
||||||
|
pop();
|
||||||
|
break;
|
||||||
|
case (time < 30):
|
||||||
|
paternArray = [3, 4]
|
||||||
|
push();
|
||||||
|
fill(255, 0, 255);
|
||||||
|
textSize(10);
|
||||||
|
textAlign(LEFT);
|
||||||
|
text("phase 3", 10, 50);
|
||||||
|
pop();
|
||||||
|
break;
|
||||||
|
case (time > 30):
|
||||||
|
paternArray = [1, 2, 3, 4, 5]
|
||||||
|
push();
|
||||||
|
fill(255, 0, 255);
|
||||||
|
textSize(10);
|
||||||
|
textAlign(LEFT);
|
||||||
|
text("phase 4", 10, 50);
|
||||||
|
pop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function spawnRandomBullet() {
|
function spawnRandomBullet() {
|
||||||
if (chosen == false) {
|
if (chosen == false) {
|
||||||
randPatern();
|
randPatern();
|
||||||
@@ -262,9 +313,9 @@ function spawnRandomBullet() {
|
|||||||
angle = 0;
|
angle = 0;
|
||||||
}
|
}
|
||||||
if (patern == 5) {
|
if (patern == 5) {
|
||||||
let nextAttack = random([1, 2, 3]);
|
let nextAttack = random([1, 2, 3, 4]);
|
||||||
if (nextAttack == 1) {
|
if (nextAttack == 1) {
|
||||||
for (let i = 0; i < random(3, 10); i++) {
|
for (let i = 0; i < random(3, 15); i++) {
|
||||||
let shotWidth = random(0, width);
|
let shotWidth = random(0, width);
|
||||||
shotPosX = shotWidth;
|
shotPosX = shotWidth;
|
||||||
shotPosY = height;
|
shotPosY = height;
|
||||||
@@ -272,7 +323,7 @@ function spawnRandomBullet() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextAttack == 2) {
|
if (nextAttack == 2) {
|
||||||
for (let i = 0; i < random(3, 10); i++) {
|
for (let i = 0; i < random(3, 15); i++) {
|
||||||
let shotWidth = random(0, width);
|
let shotWidth = random(0, width);
|
||||||
shotPosX = shotWidth;
|
shotPosX = shotWidth;
|
||||||
shotPosY = 0;
|
shotPosY = 0;
|
||||||
@@ -280,15 +331,15 @@ function spawnRandomBullet() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextAttack == 3) {
|
if (nextAttack == 3) {
|
||||||
for (let i = 0; i < random(3, 10); i++) {
|
for (let i = 0; i < random(3, 15); i++) {
|
||||||
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 / 4, shotPosX, shotPosY, hasMoved, angle));
|
bullets.push(new bullet(width, shotHeight, radius, shotSpeed / 4, shotPosX, shotPosY, hasMoved, angle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextAttack == 3) {
|
if (nextAttack == 4) {
|
||||||
for (let i = 0; i < random(3, 10); i++) {
|
for (let i = 0; i < random(3, 15); i++) {
|
||||||
let shotHeight = random(0, width);
|
let shotHeight = random(0, width);
|
||||||
shotPosX = width;
|
shotPosX = width;
|
||||||
shotPosY = shotHeight;
|
shotPosY = shotHeight;
|
||||||
|
Reference in New Issue
Block a user