From 1b340bf29d635999613f6d8a9ac2448743930a0f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 14 Mar 2026 17:20:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Enhanced=20Game=20Fee?= =?UTF-8?q?dback=20and=20Visual=20Polish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Colorize countdown and "GO!" prompt - Show live high score tracking - Use \033[K for robust line clearing - Celebrate first-time personal bests - Record UX learnings in journal Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- .Jules/palette.md | 8 ++++++++ src/main.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.Jules/palette.md b/.Jules/palette.md index c4e3778..1a40f51 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -25,3 +25,11 @@ ## 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 - Real-time Record Feedback and Robust CLI Updates +**Learning:** Real-time feedback for high scores (e.g., 'Score: 5 | High: 10') motivates players by providing a persistent target. Additionally, using the ANSI 'Erase in Line' sequence (`\033[K`) is far more robust than manual space padding for handling variable-length terminal updates, as it eliminates visual artifacts when the content shrinks. +**Action:** Use real-time record comparisons in game UIs and prioritize `\033[K` for all in-place CLI line updates. + +## 2026-05-25 - Inclusive Milestone Celebrations +**Learning:** Suppressing achievement celebrations (like "NEW BEST!") for first-time players creates a clinical and unrewarding initial experience. A player's first session is technically their first personal best and should be celebrated as such to build immediate positive reinforcement. +**Action:** Ensure achievement logic like `score > highscore` handles the `highscore == 0` case gracefully to celebrate first-time milestones. diff --git a/src/main.cpp b/src/main.cpp index e72f1da..a4d58d4 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,10 +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: " << (score > highscore ? score : highscore) << " " << (hardMode ? CLR_HARD "[HARD MODE]" : CLR_NORM "[NORMAL MODE]") - << (score > initialHighscore && initialHighscore > 0 ? " NEW BEST! 🥳" : "") - << " " << std::flush; + << (score > initialHighscore ? " NEW BEST! 🥳" : "") + << "\033[K" << std::flush; updateUI = false; } } @@ -151,7 +151,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";