Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
## 2024-05-20 - Dynamic Progress Bar for Quiet CLI Tasks
**Learning:** For long-running CLI processes that suppress verbose logging (e.g., `--quiet`), users lose system status visibility.
**Action:** Implemented a dynamic progress bar using `\r` and `flush=True`, conditional on `sys.stdout.isatty()`, to provide status feedback without polluting non-interactive logs.

## 2024-05-24 - Web Game Keyboard Controls UX
**Learning:** Using 'Space' or 'Arrow' keys to trigger interactions in web apps (like jumping in a game) without calling `e.preventDefault()` causes the browser to naturally scroll the page. This breaks the gameplay experience as the user is thrown out of context.
**Action:** Always capture and prevent default behavior on keyboard events that share bindings with native browser navigation (like Space/Arrow keys for scrolling) when implementing custom interactive widgets or games.
20 changes: 18 additions & 2 deletions src/views/mario-game.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@
font-size: 20px;
font-family: Arial;
}

#hint {
position: absolute;
top: 35px;
left: 10px;
color: rgba(255, 255, 255, 0.8);
font-size: 14px;
font-family: Arial;
}
</style>
</head>

<body>

<div id="game">
<div id="score">Score: 0</div>
<div id="score" aria-live="polite">Score: 0</div>
<div id="hint">Press Space to jump</div>
<div id="mario"></div>
<div class="ground"></div>
</div>
Expand All @@ -72,7 +82,13 @@
let score = 0;

// Jump mechanic
document.addEventListener("keydown", () => {
document.addEventListener("keydown", (e) => {
if (e.code === "Space" || e.code === "ArrowUp") {
e.preventDefault(); // Prevent page scrolling
} else {
return;
}

if (jumping) return;

jumping = true;
Expand Down
Loading