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 @@ -25,3 +25,7 @@
## 2026-03-02 - Hiding the Cursor in CLI Games
**Learning:** In terminal applications that require rapid visual updates or where user input doesn't involve typing text, an actively blinking cursor can be a visual distraction. Hiding it during interaction (`\033[?25l`) and rigorously ensuring it is restored (`\033[?25h`) on exit—including signal interrupts—significantly improves the aesthetic and focus.
**Action:** Always hide the cursor for interactive CLI games and explicitly restore it across all exit paths, including async-signal-safe signal handlers.

## 2025-01-24 - Real-time Achievement Feedback in CLI
**Learning:** In terminal-based games, displaying achievement progress (like a live high score) in real-time provides immediate tactile reward and engagement. Furthermore, inclusive UX means ensuring first-time players also receive "New Best" feedback, even when their initial record is zero.
**Action:** Update session-high-score variables immediately upon record-breaking and display them in the live HUD. Ensure achievement conditions (`score > highscore`) don't exclude the first-time user experience.
16 changes: 10 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main() {
}

for (int i = 3; i > 0; --i) {
std::cout << "\rStarting in " << i << "... " << std::flush;
std::cout << "\rStarting in " << CLR_CTRL << i << CLR_RESET << "... " << std::flush;
auto start_wait = std::chrono::steady_clock::now();
while (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_wait).count() < 1000) {
int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_wait).count();
Expand All @@ -108,7 +108,7 @@ int main() {
}
}
}
std::cout << "\rGO! \n" << std::flush;
std::cout << "\r" << CLR_NORM << "GO! " << CLR_RESET << "\n" << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
tcflush(STDIN_FILENO, TCIFLUSH);

Expand All @@ -124,22 +124,26 @@ int main() {
if (poll(fds, 1, remaining) > 0) {
if (read(STDIN_FILENO, &input, 1) <= 0 || input == 'q') break;
if (input == 'h') hardMode = !hardMode;
else score++;
else {
score++;
if (score > highscore) highscore = score;
}
updateUI = true;
}

now = std::chrono::steady_clock::now();
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_tick).count();
if (elapsed >= timeout_ms) {
score++;
if (score > highscore) highscore = score;
last_tick = now;
updateUI = true;
}

if (updateUI) {
std::cout << "\r" << CLR_SCORE << "Score: " << score << CLR_RESET << " "
std::cout << "\r" << CLR_SCORE << "Score: " << score << CLR_RESET << " | High: " << highscore << " "
<< (hardMode ? CLR_HARD "[HARD MODE]" : CLR_NORM "[NORMAL MODE]")
<< (score > initialHighscore && initialHighscore > 0 ? " NEW BEST! 🥳" : "")
<< (score > initialHighscore ? " NEW BEST! 🥳" : "")
<< " " << std::flush;
updateUI = false;
}
Expand All @@ -151,7 +155,7 @@ int main() {

tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
std::cout << "\n\n" << CLR_SCORE << "Final Score: " << score << CLR_RESET << "\n";
if (score > initialHighscore && initialHighscore > 0) {
if (score > initialHighscore) {
std::cout << "Congratulations! A new personal best!\n";
}
std::cout << "Thanks for playing!\n";
Expand Down
Loading