about summary refs log tree commit diff stats
path: root/html/broughlike/index.html
diff options
context:
space:
mode:
authorelioat <{ID}+{username}@users.noreply.github.com>2024-10-21 10:03:33 -0400
committerelioat <{ID}+{username}@users.noreply.github.com>2024-10-21 10:03:33 -0400
commit40fa780d934ec61862804d16a85cb9399d2c312b (patch)
tree6a95270e3ce81bcbd6299ebf4a47f034441b2e76 /html/broughlike/index.html
parentd5a010727cfa0399fece6734b4dfc86fee73f24e (diff)
downloadtour-40fa780d934ec61862804d16a85cb9399d2c312b.tar.gz
*
Diffstat (limited to 'html/broughlike/index.html')
-rw-r--r--html/broughlike/index.html25
1 files changed, 20 insertions, 5 deletions
diff --git a/html/broughlike/index.html b/html/broughlike/index.html
index 9afeb07..ef547e7 100644
--- a/html/broughlike/index.html
+++ b/html/broughlike/index.html
@@ -227,18 +227,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);
             });
         }
 
@@ -375,7 +390,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!");
             }