about summary refs log tree commit diff stats
path: root/html/broughlike/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'html/broughlike/index.html')
-rw-r--r--html/broughlike/index.html41
1 files changed, 34 insertions, 7 deletions
diff --git a/html/broughlike/index.html b/html/broughlike/index.html
index e0028a0..c530919 100644
--- a/html/broughlike/index.html
+++ b/html/broughlike/index.html
@@ -67,8 +67,10 @@
             pentagon: 'blueviolet', 
             player: 'rgba(0, 237, 209, ',
             enemy: 'rgba(255, 155, 28, ',
+            boss: 'rgba(255, 14, 0, ',
             combatDotPlayer: '#00edd1',
-            combatDotEnemy: '#ff731c'
+            combatDotEnemy: '#ff731c',
+            combatDotBoss: '#b70030'
         };
 
         const GRID_SIZE = 6;
@@ -76,6 +78,7 @@
         const PLAYER_MAX_HEALTH = 16;
         const PLAYER_BASE_DAMAGE = 1;
         const ENEMY_CHASE_DISTANCE = 4;
+        const ENEMY_BOSS_OCCURRENCE = 10;
         const MIN_ENEMIES_ON_LEVEL = 1;
         const MAX_ENEMIES_ON_LEVEL = 4;
         const MAX_ENEMY_HEALTH = 7;
@@ -133,8 +136,8 @@
             // Generate between 0 and MAX_ENEMIES_ON_LEVEL enemies if the player's score is 4 or lower
             // Generate between MIN_ENEMIES_ON_LEVEL and MAX_ENEMIES_ON_LEVEL enemies if the player's score is 5 or higher
             const numEnemies = player.score > 4 
-                ? Math.floor(Math.random() * (MAX_ENEMIES_ON_LEVEL - MIN_ENEMIES_ON_LEVEL + 1)) + MIN_ENEMIES_ON_LEVEL 
-                : Math.floor(Math.random() * (MAX_ENEMIES_ON_LEVEL + 1));
+            ? Math.floor(Math.random() * (MAX_ENEMIES_ON_LEVEL - MIN_ENEMIES_ON_LEVEL + 1)) + MIN_ENEMIES_ON_LEVEL 
+            : Math.floor(Math.random() * (MAX_ENEMIES_ON_LEVEL + 1));
             for (let i = 0; i < numEnemies; i++) {
                 let enemyX, enemyY;
                 do {
@@ -146,11 +149,33 @@
                     walls.some(wall => wall.x === enemyX && wall.y === enemyY)
                 );
                 enemies.push({
+                    color: COLORS.enemy,
                     x: enemyX,
                     y: enemyY,
                     health: Math.floor(Math.random() * (MAX_ENEMY_HEALTH - MIN_ENEMY_HEALTH + 1)) + MIN_ENEMY_HEALTH
                 });
             }
+
+            // Generate a boss enemy every ENEMY_BOSS_OCCURRENCE levels
+            if (player.score % ENEMY_BOSS_OCCURRENCE === 0 && player.score > 0) {
+                let bossX, bossY;
+                do {
+                    bossX = Math.floor(Math.random() * GRID_SIZE);
+                    bossY = Math.floor(Math.random() * GRID_SIZE);
+                } while (
+                    (bossX === player.x && bossY === player.y) ||
+                    (bossX === exit.x && bossY === exit.y) ||
+                    walls.some(wall => wall.x === bossX && wall.y === bossY) ||
+                    enemies.some(enemy => enemy.x === bossX && enemy.y === bossY)
+                );
+                enemies.push({
+                    isBoss: true,
+                    color: COLORS.boss,
+                    x: bossX,
+                    y: bossY,
+                    health: MAX_ENEMY_HEALTH + 2
+                });
+            }
         }
 
         function generateWallsNaive() {
@@ -463,7 +488,7 @@
 
                 ctx.beginPath();
                 ctx.arc(x, y, radius, 0, 2 * Math.PI);
-                ctx.fillStyle = `${COLORS.enemy}${opacity})`;
+                ctx.fillStyle = `${enemy.color}${opacity})`;
                 ctx.fill();
 
                 drawCharacterBorder(x, y, radius, damageTaken);
@@ -579,7 +604,9 @@
                 const distanceToPlayer = Math.abs(enemy.x - player.x) + Math.abs(enemy.y - player.y);
                 const distanceToExit = Math.abs(enemy.x - exit.x) + Math.abs(enemy.y - exit.y);
         
-                const target = distanceToPlayer <= ENEMY_CHASE_DISTANCE ? player : exit;
+                // If the enemy is closer to the exit than the player, move towards the exit
+                // Bosses are more aggressive about chasing the player
+                const target = distanceToPlayer <= (enemy.isBoss ? ENEMY_CHASE_DISTANCE + 2 : ENEMY_CHASE_DISTANCE) ? player : exit;
                 const path = findPath(enemy, target);
         
                 if (path.length > 1) {
@@ -683,7 +710,7 @@
 
             enemy.health = enemy.health - player.damage;
             player.totalDamageDone++;
-            addCombatDots(cellX, cellY, COLORS.combatDotEnemy); // Add dots for enemy damage
+            addCombatDots(cellX, cellY, enemy.isBoss ? COLORS.combatDotBoss : COLORS.combatDotEnemy); // Add dots for enemy damage
             console.log("Player hit! Enemy health: " + enemy.health);
 
             if (combatAnimationEnabled) {
@@ -729,7 +756,7 @@
             if (player.x === exit.x && player.y === exit.y) {
                 player.score += 1;
                 player.damage = PLAYER_BASE_DAMAGE;
-                console.group("Level complete! " + player.score);
+                console.groupCollapsed("Level complete! " + player.score);
                 console.log("Score: " + player.score);
                 console.log("Current health: " + player.health);
                 console.log("Distance Traveled: " + player.cellsTraveled);