diff options
author | elioat <elioat@tilde.institute> | 2024-10-24 20:49:49 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-10-24 20:49:49 -0400 |
commit | ae84a24767f516040dffcda32969e80364439223 (patch) | |
tree | 9171c09951764fa7e2c002feb818fb81de5cd272 /html/broughlike/index.html | |
parent | 533379b702ad25835105c0798ff5413d1bf095ef (diff) | |
download | tour-ae84a24767f516040dffcda32969e80364439223.tar.gz |
*
Diffstat (limited to 'html/broughlike/index.html')
-rw-r--r-- | html/broughlike/index.html | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/html/broughlike/index.html b/html/broughlike/index.html index b5a4f09..391b6b9 100644 --- a/html/broughlike/index.html +++ b/html/broughlike/index.html @@ -8,6 +8,7 @@ <style> body { background-color: #f0f0f0; + font-size: x-large; } canvas { width: 90vw; @@ -43,7 +44,8 @@ const PLAYER_MAX_HEALTH = 16; const PLAYER_BASE_DAMAGE = 1; const ENEMY_CHASE_DISTANCE = 4; - const MAX_ENEMIES_ON_LEVEL = 3; + const MIN_ENEMIES_ON_LEVEL = 1; + const MAX_ENEMIES_ON_LEVEL = 4; const MAX_ENEMY_HEALTH = 7; const MIN_ENEMY_HEALTH = 2; const WALLS_MIN = 5; @@ -52,6 +54,8 @@ const ITEMS_MAX = 3; const DOTS_PER_HIT = 7; + let highScore = localStorage.getItem('highScore') || 0; + const canvas = document.getElementById('gameCanvas'); const ctx = canvas.getContext('2d'); let tileSize = canvas.width / GRID_SIZE; @@ -94,7 +98,11 @@ function generateEnemies() { enemies = []; - const numEnemies = Math.floor(Math.random() * (MAX_ENEMIES_ON_LEVEL + 1)); // Between 0 and the constant value. + // 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)); for (let i = 0; i < numEnemies; i++) { let enemyX, enemyY; do { @@ -458,7 +466,11 @@ } if (player.health <= 0) { - 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}`); + if (player.score > highScore) { + highScore = player.score; + localStorage.setItem('highScore', highScore); + } + alert(`Score: ${player.score}\nDistance Traveled: ${player.cellsTraveled}\nTotal Damage Dealt: ${player.totalDamageDone}\nTotal Damage Received: ${player.totalDamageTaken}\n\nHigh Score: ${highScore}`); resetGame(); } } @@ -495,6 +507,7 @@ console.log("Total Damage Received: " + player.totalDamageTaken); console.log("Circles Vanquished: " + player.killCount); console.log("Items Collected: " + player.itemsCollected); + console.log("High Score: " + highScore); console.groupEnd(); combatDots = {}; generateExit(); |