added different way of angling bullets(no succes)
This commit is contained in:
29
web/game.js
29
web/game.js
@@ -36,6 +36,7 @@ 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 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
|
||||||
@@ -70,16 +71,13 @@ function life() {
|
|||||||
time = 0;
|
time = 0;
|
||||||
bounceX = bossPosX;
|
bounceX = bossPosX;
|
||||||
bounceY = bossPosY;
|
bounceY = bossPosY;
|
||||||
initialPlayerPosX = playerPosX;
|
|
||||||
initialPlayerPosY = playerPosY;
|
|
||||||
hasMoved = false;
|
|
||||||
bullets = [];
|
|
||||||
shot = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function movementCheck() {
|
function movementCheck() {
|
||||||
if (playerPosX != initialPlayerPosX || playerPosY != initialPlayerPosY) {
|
if (playerPosX != initialPlayerPosX && playerPosY != initialPlayerPosY) {
|
||||||
hasMoved = true;
|
hasMoved = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,22 +204,22 @@ function spawnRandomBullet(){
|
|||||||
nextAttack = random([1, 2, 3, 4]);
|
nextAttack = random([1, 2, 3, 4]);
|
||||||
text(nextAttack, 30, 50);
|
text(nextAttack, 30, 50);
|
||||||
if (nextAttack == 1) {
|
if (nextAttack == 1) {
|
||||||
shotPosX = 510;
|
shotPosX = 500;
|
||||||
shotPosY = 100;
|
shotPosY = 100;
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
||||||
}
|
}
|
||||||
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));
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
||||||
}
|
}
|
||||||
if (nextAttack == 3) {
|
if (nextAttack == 3) {
|
||||||
shotPosX = -10;
|
shotPosX = 0;
|
||||||
shotPosY = random(0, 600);
|
shotPosY = random(0, 600);
|
||||||
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
||||||
}
|
}
|
||||||
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));
|
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
||||||
|
|
||||||
@@ -235,11 +233,12 @@ function spawnRandomBullet(){
|
|||||||
if (patern == 3) {
|
if (patern == 3) {
|
||||||
shotPosX = 500;
|
shotPosX = 500;
|
||||||
shotPosY = 100;
|
shotPosY = 100;
|
||||||
shotPoint = 0;
|
angle = 0;
|
||||||
for (let i = 0; i < 50; i++) {
|
// changing the angle of the bullets
|
||||||
shotPoint = shotPoint + 50;
|
for (let i = 0; i < 180; i++) {
|
||||||
|
let angleChange = map(i, 0, 50, 0, 360); // Example: linear change
|
||||||
bullets.push(new bullet(0, shotPoint, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
bullets.push(new bullet(0, angle + angleChange, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
|
||||||
|
// angle += 360 / 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user