added third patern (multiple bullets at once)

This commit is contained in:
Mees Roelofsz
2023-11-30 21:10:57 +01:00
parent 4a2c3dabac
commit 8aa5b6a4a2

View File

@@ -35,6 +35,7 @@ let direction;
let framerate = 120;
let hasMoved = false;
let time = 0;
let shotPoint = 0;
//let myBullet = new bullet();
// the function setup() is called once when the page is loaded
@@ -43,6 +44,7 @@ function setup() {
createCanvas(width, height);
frameRate(framerate);
angleMode(DEGREES);
// disable the outline of shapes
Movementloop()
@@ -196,7 +198,7 @@ function randomAttackPattern(){
function spawnRandomBullet(){
let patern = random([1,2]);
let patern = random([3]);
if (patern == 1) {
nextAttack = random([1, 2, 3, 4]);
text(nextAttack, 30, 50);
@@ -227,5 +229,15 @@ function spawnRandomBullet(){
shotPosY = bounceY;
bullets.push(new bullet(playerPosX, playerPosY, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
}
if (patern == 3) {
shotPosX = 500;
shotPosY = 100;
shotPoint = 0;
for (let i = 0; i < 50; i++) {
shotPoint = shotPoint + 50;
bullets.push(new bullet(0, shotPoint, radius, shotSpeed, shotPosX, shotPosY, hasMoved));
}
}
}