diff options
-rw-r--r-- | js/puzzle-dungeon/game.js | 28 | ||||
-rw-r--r-- | js/puzzle-dungeon/index.html | 5 |
2 files changed, 17 insertions, 16 deletions
diff --git a/js/puzzle-dungeon/game.js b/js/puzzle-dungeon/game.js index 4362be8..ae2e627 100644 --- a/js/puzzle-dungeon/game.js +++ b/js/puzzle-dungeon/game.js @@ -3,7 +3,7 @@ export let player = { position: { x: 0, y: 0 }, inventory: [], health: 10, - endurance: 10, + power: 10, score: 0, steps: 0, flashing: false @@ -23,11 +23,11 @@ function createGrid(rows, cols) { } function generateCollectables(grid, numCollectables) { - const collectableTypes = ['potion', 'shield', 'food']; + const collectableTypes = ['potion', 'shield', 'battery']; const collectableColors = { - 'potion': 'purple', - 'shield': 'gold', - 'food': 'red' + 'potion': 'peachpuff', + 'shield': 'cornflowerBlue', + 'battery': 'gold' }; for (let i = 0; i < numCollectables; i++) { let x, y; @@ -47,7 +47,7 @@ function generateDamagingSpaces(grid, numSpaces) { x = Math.floor(Math.random() * grid.length); y = Math.floor(Math.random() * grid[0].length); } while (x === 0 && y === 0); // Ensure no damaging spaces at (0,0) - grid[x][y] = { type: 'damage', color: 'pink' }; + grid[x][y] = { type: 'damage', color: 'tomato' }; } } @@ -57,7 +57,7 @@ function generateTargetBlock(grid) { x = Math.floor(Math.random() * grid.length); y = Math.floor(Math.random() * grid[0].length); } while (x === 0 && y === 0); // Ensure no target block at (0,0) - grid[x][y] = { type: 'target', color: 'green' }; // Target block represented by 'X' + grid[x][y] = { type: 'target', color: 'lightgreen' }; // Target block represented by 'X' targetPosition = { x, y }; // Store the target block position } @@ -70,31 +70,31 @@ export function drawGrid(grid) { grid.forEach((row, x) => { row.forEach((cell, y) => { - ctx.strokeStyle = 'black'; + ctx.strokeStyle = '#2d2d2d'; ctx.strokeRect(x * cellSize, y * cellSize, cellSize, cellSize); if (cell && cell.color) { ctx.fillStyle = cell.color; ctx.fillRect(x * cellSize, y * cellSize, cellSize, cellSize); - ctx.fillStyle = 'black'; + ctx.fillStyle = '#2d2d2d'; ctx.font = `${cellSize / 2}px Arial`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; let char = ''; if (cell.type === 'potion') char = 'p'; if (cell.type === 'shield') char = 's'; - if (cell.type === 'food') char = 'f'; + if (cell.type === 'battery') char = 'b'; if (cell.type === 'damage') char = '!'; - if (cell.type === 'target') char = 'X'; + if (cell.type === 'target') char = '#'; ctx.fillText(char, x * cellSize + cellSize / 2, y * cellSize + cellSize / 2); } }); }); // Draw player - ctx.fillStyle = player.flashing ? 'white' : 'blue'; + ctx.fillStyle = player.flashing ? 'white' : 'thistle'; ctx.fillRect(player.position.x * cellSize, player.position.y * cellSize, cellSize, cellSize); - ctx.fillStyle = 'black'; + ctx.fillStyle = '#2d2d2d'; ctx.font = `${cellSize / 2}px Arial`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; @@ -135,7 +135,7 @@ export function updatePlayerPosition(newX, newY) { export function updatePlayerStatus() { document.getElementById('playerPosition').textContent = `Position: (${player.position.x}, ${player.position.y})`; document.getElementById('playerHealth').textContent = `Health: ${player.health}`; - document.getElementById('playerEndurance').textContent = `Endurance: ${player.endurance}`; + document.getElementById('playerPower').textContent = `Power: ${player.power}`; document.getElementById('playerInventory').textContent = `Inventory: [${player.inventory.join(', ')}]`; document.getElementById('playerScore').textContent = `Score: ${player.score}`; } diff --git a/js/puzzle-dungeon/index.html b/js/puzzle-dungeon/index.html index 3d02487..5a88fc3 100644 --- a/js/puzzle-dungeon/index.html +++ b/js/puzzle-dungeon/index.html @@ -6,6 +6,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body, html { + background-color: #f0f0f0; margin: 0; padding: 0 1em; max-width: 100%; @@ -13,7 +14,7 @@ display: block; } canvas { - border: 1px solid black; + border: 1px solid #2d2d2d; display: block; margin: 0 auto; } @@ -35,7 +36,7 @@ <body> <p> <span id="playerHealth">Health: 10</span> / - <span id="playerEndurance">Endurance: 10</span> / + <span id="playerPower">Power: 10</span> / <span id="playerScore">Score: 0</span> / <span id="playerPosition">(0, 0)</span> </p> |