format
This commit is contained in:
98
web/game.js
98
web/game.js
@@ -31,9 +31,9 @@ let bounceY = bossPosY;
|
|||||||
let predictiveBounceX;
|
let predictiveBounceX;
|
||||||
let predictiveBounceY;
|
let predictiveBounceY;
|
||||||
let bullets = [];
|
let bullets = [];
|
||||||
let direction;
|
let direction;
|
||||||
let framerate = 120;
|
let framerate = 120;
|
||||||
let hasMoved = false;
|
let hasMoved = false;
|
||||||
let time = 0;
|
let time = 0;
|
||||||
let shotPoint = 0;
|
let shotPoint = 0;
|
||||||
let angle = 0;
|
let angle = 0;
|
||||||
@@ -42,7 +42,7 @@ let angle = 0;
|
|||||||
// 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() {
|
||||||
// create a canvas element and append it to the body
|
// create a canvas element and append it to the body
|
||||||
|
|
||||||
createCanvas(width, height);
|
createCanvas(width, height);
|
||||||
frameRate(framerate);
|
frameRate(framerate);
|
||||||
angleMode(DEGREES);
|
angleMode(DEGREES);
|
||||||
@@ -54,7 +54,7 @@ function setup() {
|
|||||||
|
|
||||||
|
|
||||||
function score() {
|
function score() {
|
||||||
time += 1 / framerate;
|
time += 1 / framerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
function life() {
|
function life() {
|
||||||
@@ -71,7 +71,7 @@ function life() {
|
|||||||
time = 0;
|
time = 0;
|
||||||
bounceX = bossPosX;
|
bounceX = bossPosX;
|
||||||
bounceY = bossPosY;
|
bounceY = bossPosY;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ function draw() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomAttackPattern(){
|
function randomAttackPattern() {
|
||||||
if (shot == false || hit == true) {
|
if (shot == false || hit == true) {
|
||||||
|
|
||||||
spawnRandomBullet()
|
spawnRandomBullet()
|
||||||
@@ -202,49 +202,49 @@ function randomAttackPattern(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnRandomBullet(){
|
function spawnRandomBullet() {
|
||||||
|
|
||||||
let patern = random([1,2,3]);
|
|
||||||
if (patern == 1) {
|
|
||||||
nextAttack = random([1, 2, 3, 4]);
|
|
||||||
text(nextAttack, 30, 50);
|
|
||||||
if (nextAttack == 1) {
|
|
||||||
shotPosX = 500;
|
|
||||||
shotPosY = 100;
|
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved,0));
|
|
||||||
}
|
|
||||||
if (nextAttack == 2) {
|
|
||||||
shotPosX = random(0, 1000);
|
|
||||||
shotPosY = 600;
|
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved,0));
|
|
||||||
}
|
|
||||||
if (nextAttack == 3) {
|
|
||||||
shotPosX = 0;
|
|
||||||
shotPosY = random(0, 600);
|
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved,0));
|
|
||||||
}
|
|
||||||
if (nextAttack == 4) {
|
|
||||||
shotPosX = 1000;
|
|
||||||
shotPosY = random(0, 600);
|
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved,0));
|
|
||||||
|
|
||||||
}
|
let patern = random([1, 2, 3]);
|
||||||
}
|
if (patern == 1) {
|
||||||
if (patern == 2) {
|
nextAttack = random([1, 2, 3, 4]);
|
||||||
shotPosX = bounceX;
|
text(nextAttack, 30, 50);
|
||||||
shotPosY = bounceY;
|
if (nextAttack == 1) {
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved,0));
|
shotPosX = 500;
|
||||||
}
|
shotPosY = 100;
|
||||||
if (patern == 3) {
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
||||||
shotPosX = 500;
|
}
|
||||||
shotPosY = 100;
|
if (nextAttack == 2) {
|
||||||
angle = 0;
|
shotPosX = random(0, 1000);
|
||||||
// changing the angle of the bullets
|
shotPosY = 600;
|
||||||
for (let i = 0; i < 86; i++) {
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
||||||
bullets.push(new bullet(0, 100, radius, shotSpeed, shotPosX, shotPosY, hasMoved, angle));
|
}
|
||||||
angle -= 360 / 3;
|
if (nextAttack == 3) {
|
||||||
}
|
shotPosX = 0;
|
||||||
|
shotPosY = random(0, 600);
|
||||||
}
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
||||||
|
}
|
||||||
|
if (nextAttack == 4) {
|
||||||
|
shotPosX = 1000;
|
||||||
|
shotPosY = random(0, 600);
|
||||||
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (patern == 2) {
|
||||||
|
shotPosX = bounceX;
|
||||||
|
shotPosY = bounceY;
|
||||||
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved, 0));
|
||||||
|
}
|
||||||
|
if (patern == 3) {
|
||||||
|
shotPosX = 500;
|
||||||
|
shotPosY = 100;
|
||||||
|
angle = 0;
|
||||||
|
// changing the angle of the bullets
|
||||||
|
for (let i = 0; i < 86; i++) {
|
||||||
|
bullets.push(new bullet(0, 100, radius, shotSpeed, shotPosX, shotPosY, hasMoved, angle));
|
||||||
|
angle -= 360 / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user