From fb63d30cd1d769af5f6609a0364137ca4edd0a01 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:12:17 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Enhance=20CLI=20UX=20?= =?UTF-8?q?with=20colors=20and=20inclusive=20high=20score=20tracking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Colorized the game countdown and "GO!" prompt for better visual feedback. - Added a live high score display during gameplay. - Fixed "NEW BEST! 🥳" and final congratulations logic to trigger for first-time players. - Colorized the "NEW BEST!" and final personal best messages. - Updated `.Jules/palette.md` with new UX insights. Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- .Jules/palette.md | 4 ++++ src/main.cpp | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.Jules/palette.md b/.Jules/palette.md index c4e3778..54b9da7 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -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. + +## 2026-05-24 - Inclusive Achievement Feedback in CLI Games +**Learning:** Real-time feedback for achievements (like "NEW BEST! 🥳") should be inclusive of first-time players. Relying on a non-zero initial high score to trigger celebration messages excludes the very first moment of success a new player experiences. Displaying a live high score (e.g., `Score: X | High: max(X, record)`) provides immediate context and a target for the player. +**Action:** Ensure achievement logic triggers for first-time players by checking if `current_score > initial_high_score` (even if zero) and provide live targets in the UI. diff --git a/src/main.cpp b/src/main.cpp index e72f1da..ebd0935 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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::steady_clock::now() - start_wait).count() < 1000) { int elapsed = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_wait).count(); @@ -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); @@ -137,9 +137,10 @@ int main() { } if (updateUI) { - std::cout << "\r" << CLR_SCORE << "Score: " << score << CLR_RESET << " " + std::cout << "\r" << CLR_SCORE << "Score: " << score << CLR_RESET << " | " + << "High: " << std::max(score, initialHighscore) << " " << (hardMode ? CLR_HARD "[HARD MODE]" : CLR_NORM "[NORMAL MODE]") - << (score > initialHighscore && initialHighscore > 0 ? " NEW BEST! 🥳" : "") + << (score > initialHighscore ? CLR_NORM " NEW BEST! 🥳" CLR_RESET : "") << " " << std::flush; updateUI = false; } @@ -151,8 +152,8 @@ int main() { tcsetattr(STDIN_FILENO, TCSANOW, &oldt); std::cout << "\n\n" << CLR_SCORE << "Final Score: " << score << CLR_RESET << "\n"; - if (score > initialHighscore && initialHighscore > 0) { - std::cout << "Congratulations! A new personal best!\n"; + if (score > initialHighscore) { + std::cout << CLR_NORM << "Congratulations! A new personal best!" << CLR_RESET << "\n"; } std::cout << "Thanks for playing!\n"; std::cout << "\033[?25h" << std::flush;