From dbee67447022b4bebd6d7bccccc4e64abe974475 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:37:43 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Enhance=20CLI=20UX=20?= =?UTF-8?q?with=20color,=20live=20HUD,=20and=20inclusive=20achievements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Highlighted the "any key" interaction keyword in the start prompt. - Colorized the countdown digits (Yellow) and "GO!" prompt (Green). - Added a live "High Score" display to the gameplay HUD for real-time motivation. - Refactored achievement logic ("NEW BEST!" and congratulations) to be inclusive of first-time players. - Improved terminal UI robustness using the \033[K (Erase in Line) escape sequence. Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- src/main.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e72f1da..59695e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,7 +83,7 @@ int main() { std::cout << "Controls:\n " << CLR_CTRL << "[h]" << CLR_RESET << " Toggle Hard Mode (10x Speed!)\n " << CLR_CTRL << "[q]" << CLR_RESET << " Quit Game\n " << CLR_CTRL << "[Any key]" << CLR_RESET << " Click!\n\n"; - std::cout << "Press any key to start... " << std::flush; + std::cout << "Press " << CLR_CTRL << "any key" << CLR_RESET << " to start... " << std::flush; struct pollfd start_fds[1] = {{STDIN_FILENO, POLLIN, 0}}; if (poll(start_fds, 1, -1) > 0) { if (read(STDIN_FILENO, &input, 1) > 0 && input == 'q') { @@ -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 << "... \033[K" << 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 << "\033[K\n" << std::flush; std::this_thread::sleep_for(std::chrono::milliseconds(200)); tcflush(STDIN_FILENO, TCIFLUSH); @@ -137,10 +137,11 @@ int main() { } if (updateUI) { - std::cout << "\r" << CLR_SCORE << "Score: " << score << CLR_RESET << " " + if (score > highscore) highscore = score; + 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! 🥳" : "") - << " " << std::flush; + << (score > initialHighscore ? CLR_CTRL " NEW BEST! 🥳" CLR_RESET : "") + << "\033[K" << 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_CTRL << "Congratulations! A new personal best!" << CLR_RESET << "\n"; } std::cout << "Thanks for playing!\n"; std::cout << "\033[?25h" << std::flush;