Skip to content

Commit 8d03c07

Browse files
author
Brigit Murtaugh
committed
Enhance Pacman game by adding a fun fact feature that displays random dev container facts upon losing a life
1 parent 348e265 commit 8d03c07

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

pacman.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<a href="#pacman-game" class="pacman-link"><h1 id="pacman-game">Pacman Game</h1></a>
4343
<canvas id="pacmanCanvas" width="896" height="992"></canvas>
4444
<p>Use arrow keys to move Pacman. Collect all the whale icons while avoiding the monsters.</p>
45+
<div id="funFactContainer" style="display: none; margin: 15px auto; max-width: 600px; padding: 15px; background-color: #0066b8; color: white; border-radius: 5px; text-align: center; font-weight: bold;"></div>
4546
<button id="restartButton" class="pacman-button">Restart Game</button>
4647
<script>
4748
// Larger Pacman game (dev container themed, fewer collectibles, bigger whales)
@@ -306,6 +307,10 @@
306307
for (const monster of globalThis.monsterStates) {
307308
if (monster.x === pacman.x && monster.y === pacman.y) {
308309
lives--;
310+
311+
// Show a dev container fun fact
312+
showRandomDevContainerFact();
313+
309314
if (lives <= 0) {
310315
gameOver = true;
311316
} else {
@@ -344,6 +349,38 @@
344349
ctx.textAlign = 'left'; // Reset text align
345350
}
346351

352+
// Define dev container fun facts
353+
const devContainerFacts = [
354+
"Dev containers provide a consistent development environment for all team members!",
355+
"Dev containers can include pre-installed tools, runtimes, and dependencies!",
356+
"You can customize your dev container with VS Code extensions!",
357+
"Dev containers help eliminate 'it works on my machine' problems!",
358+
"Docker is the most common runtime used for dev containers!",
359+
"Dev containers can be used with GitHub Codespaces for cloud development!",
360+
"You can use devcontainer.json to define your development environment!",
361+
"Dev containers support port forwarding to access running services!",
362+
"Dev containers can be version-controlled alongside your code!",
363+
"You can mount your local filesystem into a dev container!",
364+
"Dev container features are reusable components for common tools!",
365+
"VS Code automatically detects dev containers in repositories!",
366+
"Dev containers can significantly reduce onboarding time for new developers!",
367+
"You can use multi-container setups with Docker Compose!",
368+
"Dev containers support GPU acceleration for ML development!"
369+
];
370+
371+
// Function to display a random dev container fun fact
372+
function showRandomDevContainerFact() {
373+
const factContainer = document.getElementById('funFactContainer');
374+
const randomFact = devContainerFacts[Math.floor(Math.random() * devContainerFacts.length)];
375+
factContainer.textContent = "Dev Container Fun Fact: " + randomFact;
376+
factContainer.style.display = 'block';
377+
378+
// Hide the fact after 5 seconds
379+
setTimeout(() => {
380+
factContainer.style.display = 'none';
381+
}, 5000);
382+
}
383+
347384
// Reset game state
348385
function resetGame() {
349386
// Reset map (restore dots)
@@ -378,6 +415,9 @@
378415
// Reset pacman
379416
pacman = { x: 14, y: 17, dx: 0, dy: 0, nextDx: 0, nextDy: 0 };
380417

418+
// Hide fun fact container
419+
document.getElementById('funFactContainer').style.display = 'none';
420+
381421
// Reset monsters to original positions
382422
globalThis.monsterStates = monsters.map(m => ({...m, dx: 0, dy: 0}));
383423

0 commit comments

Comments
 (0)