about summary refs log tree commit diff stats
path: root/html/broughlike
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-10-23 08:07:01 -0400
committerelioat <elioat@tilde.institute>2024-10-23 08:07:01 -0400
commit574924da31eb6ddf653caf84adacfbd78b5cfd49 (patch)
treeb5e20318822003b076b8393b2fcf7f0a965af604 /html/broughlike
parent9398fff65f10b01fb0cad35f9ad71ac46452d7b5 (diff)
parent8aa57714f30a29558e949bd7b52c0ea9cafec1fb (diff)
downloadtour-574924da31eb6ddf653caf84adacfbd78b5cfd49.tar.gz
Merge branch 'master' of tilde.institute:~/public_repos/tour
Diffstat (limited to 'html/broughlike')
-rw-r--r--html/broughlike/index.html37
1 files changed, 30 insertions, 7 deletions
diff --git a/html/broughlike/index.html b/html/broughlike/index.html
index 9afeb07..e643527 100644
--- a/html/broughlike/index.html
+++ b/html/broughlike/index.html
@@ -64,7 +64,9 @@
             damage: PLAYER_BASE_DAMAGE,
             totalDamageDone: 0,
             totalDamageTaken: 0,
-            cellsTraveled: 0
+            cellsTraveled: 0,
+            killCount: 0,
+            itemsCollected: 0
         };
 
         const exit = { x: Math.floor(Math.random() * GRID_SIZE), y: Math.floor(Math.random() * GRID_SIZE) };
@@ -227,18 +229,33 @@
             });
         }
 
+        function drawCharacterBorder(x, y, radius, damageTaken) {
+            const dashLength = 5;
+            const gapLength = Math.max(1, damageTaken * 2); // More damage, larger gaps
+
+            ctx.lineWidth = 2;
+            ctx.strokeStyle = '#2d2d2d';
+            ctx.setLineDash([dashLength, gapLength]);
+            ctx.beginPath();
+            ctx.arc(x, y, radius, 0, 2 * Math.PI);
+            ctx.stroke();
+            ctx.setLineDash([]); // Reset to a solid line
+        }
+
         function drawEnemies() {
             enemies.forEach(enemy => {
                 const x = enemy.x * tileSize + tileSize / 2;
                 const y = enemy.y * tileSize + tileSize / 2;
                 const opacity = enemy.health / MAX_ENEMY_HEALTH; // Opacity based on health
+                const radius = tileSize / 3;
+                const damageTaken = MAX_ENEMY_HEALTH - enemy.health;
+
                 ctx.beginPath();
-                ctx.arc(x, y, tileSize / 3, 0, 2 * Math.PI);
+                ctx.arc(x, y, radius, 0, 2 * Math.PI);
                 ctx.fillStyle = `${COLORS.enemy}${opacity})`;
                 ctx.fill();
-                ctx.lineWidth = 2;
-                ctx.strokeStyle = '#2d2d2d';
-                ctx.stroke();
+
+                drawCharacterBorder(x, y, radius, damageTaken);
             });
         }
 
@@ -283,6 +300,7 @@
         function handleItemCollection() {
             const collectedItem = items.find(item => item.x === player.x && item.y === player.y);
             if (collectedItem) {
+                player.itemsCollected++;
                 if (collectedItem.type === 'diamond') {
                     player.damage += 3;
                     console.log("Collected diamond! +3 damage on this level.");
@@ -375,7 +393,7 @@
                 player.totalDamageTaken++;
                 addCombatDots(cellX, cellY, COLORS.combatDotPlayer); // Add dots for player damage
                 console.log("Enemy hit! Player health: " + player.health);
-            } else {
+            } else {                
                 console.log("Enemy missed!");
             }
 
@@ -385,11 +403,12 @@
             console.log("Player hit! Enemy health: " + enemy.health);
 
             if (enemy.health <= 0) {
+                player.killCount++;
                 enemies = enemies.filter(e => e !== enemy);
             }
 
             if (player.health <= 0) {
-                alert(`Dead\n\nScore: ${player.score}\nDistance Traveled: ${player.cellsTraveled}\nTotal Damage Dealt: ${player.totalDamageDone}\nTotal Damage Received: ${player.totalDamageTaken}`);
+                alert(`Dead\n\nScore: ${player.score}\nDistance Traveled: ${player.cellsTraveled}\nTotal Damage Dealt: ${player.totalDamageDone}\nTotal Damage Received: ${player.totalDamageTaken}\nCircles Vanquished: ${player.killCount}\nItems Collected: ${player.itemsCollected}`);
                 resetGame();
             }
         }
@@ -402,6 +421,8 @@
             player.totalDamageTaken = 0;
             player.cellsTraveled = 0;
             player.score = 0;
+            player.killCount = 0;
+            player.itemsCollected = 0;
             player.x = 0;
             player.y = 0;
             combatDots = {};
@@ -422,6 +443,8 @@
                 console.log("Distance Traveled: " + player.cellsTraveled);
                 console.log("Total Damage Dealt: " + player.totalDamageDone);
                 console.log("Total Damage Received: " + player.totalDamageTaken);
+                console.log("Circles Vanquished: " + player.killCount);
+                console.log("Items Collected: " + player.itemsCollected);
                 console.groupEnd();
                 combatDots = {};
                 generateExit();