this is stopping the boss to keep going what's wrong with this
Assistant
<script>
const gameContainer = document.getElementById('game-container');
const gameWorld = document.getElementById('game-world');
const player = document.getElementById('player');
const scoreDisplay = document.getElementById('score');
const livesDisplay = document.getElementById('lives');
const levelDisplay = document.getElementById('level');
const timerDisplay = document.getElementById('timer');
const instructions = document.getElementById('instructions');
const cutscene = document.getElementById('cutscene');
const levelIntro = document.getElementById('level-intro');
const levelText = document.getElementById('level-text');
const bossFightScreen = document.getElementById('boss-fight');
const gameOverScreen = document.getElementById('game-over');
const intro = document.getElementById('intro');
const dialoguePara = document.querySelector('#dialogue p');
const bossHallway = document.getElementById('boss-hallway');
const bossHealthBar = document.getElementById('boss-health-bar');
const bossHealthDisplay = document.getElementById('boss-health');
const powerUpMessage = document.getElementById('power-up-message');
const interactMessage = document.getElementById('interact-message');
const friend = document.getElementById('friend');
let playerPositionX = 50;
let playerPositionY = 0;
let playerVelocityX = 0;
let playerVelocityY = 0;
let playerMaxSpeed = 5;
const playerJumpStrength = 12;
let jumpCount = 0;
const maxJumps = 2;
let isDoubleJumpEnabled = false;
let isJumping = false;
let isPaused = false;
let canShoot = true;
let bossAttacking = false;
let bossAttackPhase = 0;
let gameInterval;
let obstacles = [];
let enemies = [];
let bullets = [];
let powerUps = [];
let platforms = [];
let bossDoors = [];
let coins = [];
let score = 0;
let lives = 3;
let level = localStorage.getItem('playerLevel') ? parseInt(localStorage.getItem('playerLevel')) : 1;
const gravity = 0.5;
const maxLevels = 5;
let movingLeft = false, movingRight = false;
let currentDirection = 1;
let currentPowerUp = null;
let powerUpTimer = 0;
let gameScrollPosition = 0;
const bossScoreThreshold = 1;
const dialogues = [
"Player: Hey friend! What a nice day for an adventure!",
"Friend: Indeed! Maybe we should explore the caves.",
"Player: What's that over there? Is it the King?",
"King: Haha, I've found you! You're coming with me!",
"Friend: Player, help me!"
];
let dialogueIndex = 0;
let boss = null;
let bossHealth = 100;
let bossShielded = true;
let bossPowerObtained = false;
let bossFightActive = false;
const allPowerUpTypes = [
"super-speed", "invincibility", "teleportation", "time-freeze",
"gravity-reversal", "reflective-shield", "double-shot", "extra-life",
"score-boost", "mega-jump", "ice", "fire", "levitate", "hypno", "shield",
"regeneration", "ghost", "magnet", "invisibility", "freeze", "clone",
"shockwave", "energy", "shrink", "grow", "heal", "boss-power-up",
"speed-bullet", "rapid-fire", "spike", "anti-gravity", "energy-blast",
"light-speed", "blazing-trail", "sonic-wave", "armor", "telekinetic",
"camouflage", "dimension-shift", "energy-drain", "mind-control",
"hologram"
];
window.addEventListener('keydown', handleKeydown);
window.addEventListener('keyup', handleKeyup);
function handleKeydown(e) {
switch (e.key) {
case 'ArrowLeft':
movingLeft = true;
currentDirection = -1;
break;
case 'ArrowRight':
movingRight = true;
currentDirection = 1;
break;
case 'ArrowUp':
handleJump();
break;
case ' ': // Space bar for shooting
if (canShoot) {
shootBullet(currentDirection);
canShoot = false;
setTimeout(() => canShoot = true, 300);
}
break;
case 'z':
case 'Z': // Power-Up activation
if (currentPowerUp) { // Check if there is a power-up to use
usePowerUp();
} else if (bossPowerObtained) { // Charge if the boss power is obtained and no power-up is active
isCharging = true;
chargeTime = 0;
}
break;
case 'e':
case 'E':
interact(); // Trigger the interact function when 'E' is pressed
break;
}
}
function handleKeyup(e) {
switch (e.key) {
case 'ArrowLeft':
movingLeft = false;
break;
case 'ArrowRight':
movingRight = false;
break;
case 'z':
case 'Z':
if (bossPowerObtained && isCharging) {
isCharging = false;
shootLaserBlast(chargeTime);
}
break;
}
}
function handleJump() {
if (playerPositionY <= 0 || (isDoubleJumpEnabled && jumpCount < maxJumps)) {
playerVelocityY = playerJumpStrength;
jumpCount++;
isJumping = true;
}
}
function nextDialogue() {
if (dialogueIndex < dialogues.length - 1) {
dialogueIndex++;
dialoguePara.textContent = dialogues[dialogueIndex];
} else {
intro.style.display = 'none';
startGame();
}
}
function shootBullet(direction) {
const bullet = createBullet(direction);
bullets.push({ element: bullet, direction });
gameWorld.appendChild(bullet);
if (currentPowerUp === 'double-shot') {
const altBullet = createBullet(direction + 1);
bullets.push({ element: altBullet, direction });
gameWorld.appendChild(altBullet);
}
if (currentPowerUp === 'speed-bullet') {
const sideBullet1 = createBullet(direction + 6);
const sideBullet2 = createBullet(direction - 6);
bullets.push({ element: sideBullet1, direction });
bullets.push({ element: sideBullet2, direction });
gameWorld.appendChild(sideBullet1);
gameWorld.appendChild(sideBullet2);
}
}
function createBurst(x, y) {
const burst = document.createElement('div');
burst.classList.add('burst');
burst.style.left = x + 'px';
burst.style.bottom = y + 'px';
gameWorld.appendChild(burst);
setTimeout(() => burst.remove(), 500);
}
function summonAllies() {
for (let i = 0; i < 3; i++) {
let ally = createElement('ally', [], parseInt(player.style.left) + (i * 30));
ally.style.bottom = player.style.bottom;
gameWorld.appendChild(ally);
function interact() {
if (checkCollision(player, friend)) {
activateFriendDialogue();
}
bossDoors.forEach(door => {
if (checkCollision(player, door)) {
if (score >= level * bossScoreThreshold) {
openBossHallway();
} else {
displayMessage("You need more score to enter the boss area!");
}
}
});
}
function openBossHallway() {
bossHallway.style.display = 'flex';
clearAllElements();
clearInterval(gameInterval);
}
function startBossFight() {
bossHallway.style.display = 'none';
triggerBossFight();
gameInterval = setInterval(gameLoop, 1000 / 60); // Ensure the game loop is running for updates
}
function incrementLevel() {
level++;
playerMaxSpeed = 5; // Reset speed back to normal
if (level > maxLevels) {
endGame(true);
} else {
localStorage.setItem('playerLevel', level);
updateDisplay();
resetGame();
levelIntro.style.display = 'flex';
switchLevelBackground();
levelText.textContent = `Level ${level}: New Challenges Await!`;
}
}
function switchLevelBackground() {
const backgrounds = ['#333', '#1E90FF', '#228B22', '#E0FFFF', '#B22222'];
gameContainer.style.backgroundColor = backgrounds[(level - 1) % backgrounds.length];
}
function continueGame() {
levelIntro.style.display = 'none';
gameInterval = setInterval(gameLoop, 1000 / 60);
}
function gameLoop() {
if (!isPaused) {
updatePlayerPosition(); // Ensure this is called
spawnEntities(); // You may want to stop spawning entities during the boss fight
moveElements(); // This is optional, depending on your design
checkScoreForLevelTransition(); // This can also be conditional
}
}
function cycleBossAttacks() {
if (bossHealth <= 0) {
return; // Exit if the boss is defeated
}
bossAttacking = true;
bossShielded = true;
boss.classList.add('boss-shielded'); // Show shield effect
// Function to handle the completion of attacks
function completeAttack() {
bossShielded = false;
boss.classList.remove('boss-shielded'); // Remove shield effect
displayMessage("Boss shield is OFF! Attack now!");
bossAttacking = false; // Reset attacking state
// Start the next attack cycle after a short delay
setTimeout(cycleBossAttacks, 3000); // Give players time to react
}
// Determine which attack phase to use
switch (bossAttackPhase) {
case 0:
bossEnemyBarrage(completeAttack); // Pass completeAttack as a callback
break;
case 1:
bossTargetSlam(completeAttack); // Pass completeAttack as a callback
break;
case 2:
bossExplosionRain(completeAttack); // Pass completeAttack as a callback
break;
case 3:
bossNewPower(completeAttack); // Pass completeAttack as a callback
break;
}
// Cycle through the attack phases
bossAttackPhase = (bossAttackPhase + 1) % 4; // Now cycling through 4 phases
}
function bossEnemyBarrage() {
boss.style.animation = "boss-shake 1s infinite alternate"; // Boss shakes
let spawnCount = 0;
let spawnInterval = setInterval(() => {
if (spawnCount >= 10) { // Stops after 10 spawns
clearInterval(spawnInterval);
boss.style.animation = ""; // Stop shaking
setTimeout(cycleBossAttacks, 3000); // Cooldown before next attack
return;
}
let enemy = createElement('enemy', enemies, Math.random() * gameContainer.offsetWidth);
enemy.style.bottom = "400px"; // Start from top
let fallSpeed = 8;
let fallInterval = setInterval(() => {
enemy.style.bottom = (parseInt(enemy.style.bottom) - fallSpeed) + "px";
if (parseInt(enemy.style.bottom) <= 0) {
enemy.style.bottom = "0px"; // Stop at ground level
clearInterval(fallInterval);
}
// Check for collision with player
if (checkCollision(player, enemy)) {
reduceLives();
enemy.remove();
clearInterval(fallInterval);
}
}, 50);
spawnCount++;
}, 500); // Spawn every half second
}
function bossTargetSlam() {
let slamCount = 0;
boss.style.animation = "boss-shake 0.5s infinite alternate";
let followInterval = setInterval(() => {
if (slamCount >= 3) {
clearInterval(followInterval);
boss.style.animation = "";
boss.style.bottom = "100px"; // Reset position after all slams
setTimeout(cycleBossAttacks, 3000);
return;
}
// Position the boss over the player first
boss.style.left = player.style.left;
boss.style.bottom = "400px"; // Start at high position
let warningLine = document.createElement('div');
warningLine.classList.add('warning-line');
warningLine.style.left = player.style.left;
warningLine.style.bottom = "0px";
warningLine.style.width = "30px";
warningLine.style.height = "5px";
warningLine.style.backgroundColor = "red";
warningLine.style.position = "absolute";
gameWorld.appendChild(warningLine);
setTimeout(() => {
warningLine.remove();
// Slam down
boss.style.bottom = "100px"; // Slam down position
createBurst(parseInt(boss.style.left) + boss.offsetWidth / 2, 30); // Create burst effect
// Check collision with player
if (checkCollision(boss, player)) {
reduceLives(); // Deal damage to the player
}
// Move the boss back up after the slam
setTimeout(() => {
boss.style.bottom = "0px"; // Move back up after slam
}, 500);
}, 1000); // Time until the slam occurs
slamCount++;
}, 2000); // Time interval between slams
}
function bossExplosionRain() {
boss.style.animation = "boss-shake 1s infinite alternate";
let dropCount = 0;
let dropInterval = setInterval(() => {
if (dropCount >= 10) {
clearInterval(dropInterval);
boss.style.animation = "";
setTimeout(cycleBossAttacks, 3000); // Cooldown before next attack
return;
}
// Randomize the X position based on the player's position
let playerPositionX = parseInt(player.style.left);
let explosionBlock = document.createElement('div'); // Corrected to use document.createElement
explosionBlock.classList.add('explosive-block'); // Add a class if you want to style it later
explosionBlock.style.position = "absolute"; // Important for positioning
explosionBlock.style.left = (playerPositionX + Math.random() * 30 - 15) + "px"; // Randomize the horizontal position
explosionBlock.style.bottom = "400px"; // Start high
explosionBlock.style.width = "30px"; // Width of the falling block
explosionBlock.style.height = "10px"; // Height of the falling block
explosionBlock.style.backgroundColor = "red"; // Color of the falling block
gameWorld.appendChild(explosionBlock);
let fallSpeed = 5; // Speed of fall
let fallInterval = setInterval(() => {
explosionBlock.style.bottom = (parseInt(explosionBlock.style.bottom) - fallSpeed) + "px";
if (parseInt(explosionBlock.style.bottom) <= 0) {
createBurst(parseInt(explosionBlock.style.left), 0); // Create burst effect
if (checkCollision(explosionBlock, player)) {
reduceLives(); // Reduce lives if hit
}
explosionBlock.remove(); // Remove block once it hits ground
clearInterval(fallInterval);
}
}, 50); // Update every 50ms
dropCount++;
}, 1000); // Drop every second
}
function bossNewPower() {
let shotsFired = 0;
const maxShots = 10;
const shotCooldown = 1000; // 1 second between shots
let shootInterval = setInterval(() => {
if (shotsFired >= maxShots) {
clearInterval(shootInterval);
return; // Stop firing after maximum shots
}
// Calculate the boss's and player's positions
const bossX = parseInt(boss.style.left) + boss.offsetWidth / 2; // Middle of the boss
const bossY = parseInt(boss.style.bottom) + 30; // Just above the boss
const playerX = parseInt(player.style.left) + player.offsetWidth / 2; // Middle of the player
const playerY = parseInt(player.style.bottom); // Bottom of the player
// Calculate the direction vector
const dx = playerX - bossX;
const dy = playerY - bossY;
const distance = Math.sqrt(dx * dx + dy * dy);
const velocity = 10; // Speed of the projectile
// Create a projectile
const projectile = document.createElement('div');
projectile.classList.add('boss-projectile');
projectile.style.width = '10px';
projectile.style.height = '10px';
projectile.style.backgroundColor = 'orange';
projectile.style.position = 'absolute';
projectile.style.left = `${bossX - 5}px`; // Center it
projectile.style.bottom = `${bossY}px`; // Start just above the boss
gameWorld.appendChild(projectile);
let projectileInterval = setInterval(() => {
// Move projectile towards the player
const moveX = (dx / distance) * velocity; // Calculate x movement
const moveY = (dy / distance) * velocity; // Calculate y movement
projectile.style.left = (parseInt(projectile.style.left) + moveX) + 'px';
projectile.style.bottom = (parseInt(projectile.style.bottom) + moveY) + 'px';
// Check collision
if (checkCollision(player, projectile)) {
reduceLives(); // Reduce player lives on hit
projectile.remove(); // Remove projectile on hit
clearInterval(projectileInterval);
}
// Remove projectile if it goes off-screen
if (parseInt(projectile.style.bottom) > gameContainer.offsetHeight ||
parseInt(projectile.style.left) < 0 ||
parseInt(projectile.style.left) > gameContainer.offsetWidth) {
projectile.remove(); // Remove off-screen
clearInterval(projectileInterval);
}
}, 50); // Update every 50ms
shotsFired++;
}, shotCooldown); // Fire every second
}
function displayBossHealth() {
bossHealthBar.style.display = 'block';
updateBossHealth();
}
function updateBossHealth() {
bossHealthDisplay.style.width = `${bossHealth}%`;
}
function spawnBossEnemies() {
if (bossShielded) {
for (let i = 0; i < 2; i++) {
const enemy = createElement('enemy', enemies, parseInt(boss.style.left) + (i * 50));
enemy.style.bottom = `${Math.random() * 250}px`;
}
}
}
function spawnBossBullets() {
const bullet = createBullet();
bullet.style.left = parseInt(boss.style.left) + 'px';
bullet.style.bottom = parseInt(boss.style.bottom) + 30 + 'px';
bullet.style.backgroundColor = 'orange';
gameWorld.appendChild(bullet);
bullets.push({ element: bullet, direction: -1 });
}
function checkBossHit() {
if (!boss || bossShielded) return; // Stop draining health if shield is active
function moveChargingEnemies() {
enemies.forEach((enemy, index) => {
if (enemy.classList.contains('charging-enemy')) {
let chargeTime = parseInt(enemy.getAttribute('data-charge'));
if (chargeTime < 60) {
// Charging phase (fading in/out glow)
enemy.setAttribute('data-charge', chargeTime + 1);
} else {
// Fully Charged (Solid Red Outline + Charging Forward)
enemy.classList.remove('charging-prep');
enemy.classList.add('charging-active');
enemy.style.left = (parseInt(enemy.style.left) - 6) + 'px';
// Create a bright red trail
createChargeTrail(parseInt(enemy.style.left), parseInt(enemy.style.bottom));
}
// Check collision with player
if (checkCollision(player, enemy)) {
createBurst(parseInt(enemy.style.left), parseInt(enemy.style.bottom)); // Impact explosion
reduceLives();
removeElement(enemy, enemies, index, 0);
}
// Remove if out of bounds
if (parseInt(enemy.style.left) < gameScrollPosition - enemy.offsetWidth) {
removeElement(enemy, enemies, index, 30);
}
}
});
Your script represents a well-structured HTML and JavaScript framework for an adventure game. The game includes various mechanics including character movement, jumping, enemy encounters, power-ups, and a boss fight. Here’s an overview of how the script works, and then I'll highlight some areas you might want to modify or enhance.
Overview of the Code Structure
HTML Structure:
The HTML part contains a simple structure with elements for displaying the score, lives, level, and timer, along with various screens for game instructions, cutscenes, level intros, boss fights, and game over.
CSS Styling:
The CSS styles define the appearance of various elements, such as the player, enemies, power-ups, and the game container. It uses animations for elements like jumping, bosses, and bullets.
JavaScript Logic:
The script contains the core game functionality, defining variables for the player's state, game entities (enemies, power-ups, etc.), and game mechanics like collision detection, player interactions, enemy behavior, and boss fight logic.
Key functions include movement control, shooting mechanics, spawning enemies and power-ups, interacting with objects, and managing game state (start, end, transitioning levels).
Areas for Improvement & Suggestions
Game Balance:
You may want to adjust enemy difficulty, the scoring system, and power-up effectiveness to ensure a balanced gameplay experience.
Enhance Visuals:
Consider adding images or sprites for characters and enemies instead of colored divs for a richer graphical experience.
Sound Effects:
Implement sound effects for actions like jumping, shooting, and enemy hits to enhance immersion.
Code Refactoring:
Modularize the code into smaller functions or classes to make it easier to manage and update. For example, create separate functions to handle different types of enemies and their specific behaviors.
Responsive Design:
Ensure that the game scales correctly on different screen sizes. This might involve using relative units or media queries in your CSS.
Documentation:
Add comments or documentation to your functions and sections of code to help other developers (or your future self) understand the logic and flow of the game.
User Interface Enhancements:
Consider improving the UI, making it more intuitive and visually appealing. Adjust the design of buttons and instructions to provide clearer guidance to players.
Enhanced Enemy AI:
Implement more sophisticated AI behaviors for enemies, such as pathfinding or different attack strategies.
Networking (if multiplayer):
If you're considering making this a multiplayer game, you'd need to think about how to handle player interactions over a network.
Conclusion
Your game framework looks robust and well-structured for a 2D adventure game concept. Incorporating the suggestions above can help improve gameplay, maintainability, and user experience. If you have specific features you want help implementing or issues you're encountering, feel free to ask!
function bossNewPower() {
let shotsFired = 0;
const maxShots = 15;
const shotCooldown = 800; // 1 second between shots
let shootInterval = setInterval(() => {
if (shotsFired >= maxShots) {
clearInterval(shootInterval);
return; // Stop firing after maximum shots
}
// Calculate the boss's and player's positions
const bossX = parseInt(boss.style.left) + boss.offsetWidth / 2; // Middle of the boss
const bossY = parseInt(boss.style.bottom) + 30; // Just above the boss
const playerX = parseInt(player.style.left) + player.offsetWidth / 2; // Middle of the player
const playerY = parseInt(player.style.bottom); // Bottom of the player
// Calculate the direction vector
const dx = playerX - bossX;
const dy = playerY - bossY;
const distance = Math.sqrt(dx * dx + dy * dy);
const velocity = 10; // Speed of the projectile
// Create a projectile
const projectile = document.createElement('div');
projectile.classList.add('boss-projectile');
projectile.style.width = '10px';
projectile.style.height = '10px';
projectile.style.backgroundColor = 'orange';
projectile.style.position = 'absolute';
projectile.style.left = `${bossX - 5}px`; // Center it
projectile.style.bottom = `${bossY}px`; // Start just above the boss
gameWorld.appendChild(projectile);
let projectileInterval = setInterval(() => {
// Move projectile towards the player
const moveX = (dx / distance) * velocity; // Calculate x movement
const moveY = (dy / distance) * velocity; // Calculate y movement
projectile.style.left = (parseInt(projectile.style.left) + moveX) + 'px';
projectile.style.bottom = (parseInt(projectile.style.bottom) + moveY) + 'px';
// Check collision
if (checkCollision(player, projectile)) {
reduceLives(); // Reduce player lives on hit
projectile.remove(); // Remove projectile on hit
clearInterval(projectileInterval);
}
// Remove projectile if it goes off-screen
if (parseInt(projectile.style.bottom) > gameContainer.offsetHeight ||
parseInt(projectile.style.left) < 0 ||
parseInt(projectile.style.left) > gameContainer.offsetWidth) {
projectile.remove(); // Remove off-screen
clearInterval(projectileInterval);
}
}, 50); // Update every 50ms
shotsFired++;
}, shotCooldown); // Fire every second
}
The bossNewPower() function you posted handles the creation and movement of boss projectiles, but it stops the boss from continuing its attacking behavior after the defined number of shots (maxShots). The issue likely lies in how the function is calling clearInterval(shootInterval) when the maximum number of shots has been fired, which prevents further attacks from the boss.
To ensure that the boss can continue attacking after firing a set number of projectiles, you need to implement a cycle that allows the boss to execute new phases or attack types after it finishes firing the projectiles. Here are some suggestions on how to modify your code to maintain the boss's attack behavior:
Suggested Modifications
Use Attack Phases:
Instead of having a linear cycle where the boss only fires projectiles up to a certain limit, you can create various attack phases. After the projectile attack is complete, you can call a different attack function or re-initiate the old one.
Implement a Cooldown After Attacks:
After firing the projectiles, set a cooldown period before the boss can initiate another attack phase. This way, the boss can switch to new strategies.
Here’s how you might revise the bossNewPower() function:
function bossNewPower() {
let shotsFired = 0;
const maxShots = 15;
const shotCooldown = 800; // 0.8 seconds between shots
const shootInterval = setInterval(() => {
if (shotsFired >= maxShots) {
clearInterval(shootInterval);
// Introduce a delay before invoking the next attack or phase
setTimeout(() => {
cycleBossAttacks(); // Call back the attack cycle function
}, 2000); // 2 seconds for any cooling down or animation effect
return; // Stop firing after maximum shots
}
// Calculate the boss's and player's positions
const bossX = parseInt(boss.style.left) + boss.offsetWidth / 2; // Middle of the boss
const bossY = parseInt(boss.style.bottom) + 30; // Just above the boss
const playerX = parseInt(player.style.left) + player.offsetWidth / 2; // Middle of the player
const playerY = parseInt(player.style.bottom); // Bottom of the player
// Calculate the direction vector
const dx = playerX - bossX;
const dy = playerY - bossY;
const distance = Math.sqrt(dx * dx + dy * dy);
const velocity = 10; // Speed of the projectile
// Create a projectile
const projectile = document.createElement('div');
projectile.classList.add('boss-projectile');
projectile.style.width = '10px';
projectile.style.height = '10px';
projectile.style.backgroundColor = 'orange';
projectile.style.position = 'absolute';
projectile.style.left = `${bossX - 5}px`; // Center it
projectile.style.bottom = `${bossY}px`; // Start just above the boss
gameWorld.appendChild(projectile);
let projectileInterval = setInterval(() => {
// Move projectile towards the player
const moveX = (dx / distance) * velocity; // Calculate x movement
const moveY = (dy / distance) * velocity; // Calculate y movement
projectile.style.left = (parseInt(projectile.style.left) + moveX) + 'px';
projectile.style.bottom = (parseInt(projectile.style.bottom) + moveY) + 'px';
// Check collision
if (checkCollision(player, projectile)) {
reduceLives(); // Reduce player lives on hit
projectile.remove(); // Remove projectile on hit
clearInterval(projectileInterval);
}
// Remove projectile if it goes off-screen
if (parseInt(projectile.style.bottom) > gameContainer.offsetHeight ||
parseInt(projectile.style.left) < 0 ||
parseInt(projectile.style.left) > gameContainer.offsetWidth) {
projectile.remove(); // Remove off-screen
clearInterval(projectileInterval);
}
}, 50); // Update every 50ms
shotsFired++;
}, shotCooldown); // Fire every 0.8 seconds
}
Key Changes:
Cooldown Logic: After firing the maximum number of shots, the shootInterval is cleared, and after a short cooldown period (here set to 2 seconds), you invoke the cycleBossAttacks() function again to bring the boss back into its attacking logic.
This approach allows the boss to transition between different attack patterns rather than just stopping after shooting projectiles, keeping the game engaging and challenging.
Make sure to adjust the timing to fit the pacing of your game for a smoother experience.