From 0b100687b61875efed331db7a0ec75b9c2302955 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 17:28:17 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Add=20start=20pro?= =?UTF-8?q?mpt=20and=203-second=20countdown=20for=20better=20UX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added "Press any key to start" prompt - Implemented 3-second animated countdown (3-2-1-GO) - Added tcflush to clear input buffer before game starts - Fixed missing color macros and cleaned up redundant code - Ensured proper color reset to prevent terminal color bleeding Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- .Jules/palette.md | 4 ++++ src/main.cpp | 26 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.Jules/palette.md b/.Jules/palette.md index 8aed79d..a7ae2e2 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -17,3 +17,7 @@ ## 2026-02-13 - Tactile Feedback in CLI **Learning:** In terminal-based games, users expect immediate visual feedback for their actions. Relying on a periodic "tick" to update the UI creates a laggy feel. Using `poll()` with a dynamic timeout allows the application to remain idle yet wake up instantly to process and render user input. **Action:** Always trigger a UI refresh immediately after processing user input in CLI applications, and use efficient waiting mechanisms (like `poll`) that can be interrupted by input. + +## 2025-05-15 - Improving Game Readiness in CLI +**Learning:** Transitioning directly from instructions to a high-speed game loop can be jarring. A "Press any key to start" prompt followed by a timed countdown (3-2-1-GO) gives the user time to prepare. Furthermore, using `tcflush` after the countdown is critical to ensure that any accidental keypresses during the preparation phase do not unfairly affect the game state. +**Action:** Use animated countdowns and input buffer flushing for time-sensitive CLI interactions. diff --git a/src/main.cpp b/src/main.cpp index 1b74c74..86a6839 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,12 @@ #include #include +#define CLR_SCORE "\033[1;32m" +#define CLR_HARD "\033[1;31m" +#define CLR_NORM "\033[1;34m" +#define CLR_CTRL "\033[1;33m" +#define CLR_RESET "\033[0m" + int main() { struct termios oldt, newt; tcgetattr(STDIN_FILENO, &oldt); @@ -14,12 +20,19 @@ int main() { tcsetattr(STDIN_FILENO, TCSANOW, &newt); int score = 0; bool hardMode = false; char input; - std::cout << YELLOW << "==========================\n SPEED CLICKER\n==========================\n" << RESET - << "Controls:\n " << YELLOW << "[h]" << RESET << " Toggle Hard Mode (10x Speed!)\n " - << YELLOW << "[q]" << RESET << " Quit Game\n " << YELLOW << "[Any key]" << RESET << " Click!\n\n"; std::cout << CLR_CTRL << "==========================\n SPEED CLICKER\n==========================\n" << CLR_RESET << "Controls:\n " << CLR_CTRL << "[h]" << CLR_RESET << " Toggle Hard Mode (10x Speed!)\n " - << CLR_CTRL << "[q]" << CLR_RESET << " Quit Game\n [Any key] Click!\n\n"; + << CLR_CTRL << "[q]" << CLR_RESET << " Quit Game\n " << CLR_CTRL << "[Any key]" << CLR_RESET << " Click!\n\n"; + + std::cout << CLR_CTRL << "Press any key to start..." << CLR_RESET << std::flush; + read(STDIN_FILENO, &input, 1); + + for (int i = 3; i > 0; --i) { + std::cout << "\r" << CLR_SCORE << "Starting in " << i << "..." << CLR_RESET << " " << std::flush; + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + std::cout << "\r" << CLR_SCORE << "GO! " << CLR_RESET << std::endl; + tcflush(STDIN_FILENO, TCIFLUSH); struct pollfd fds[1] = {{STDIN_FILENO, POLLIN, 0}}; auto last_tick = std::chrono::steady_clock::now(); @@ -46,12 +59,9 @@ int main() { } if (updateUI) { - std::cout << GREEN << "Score: " << score << RESET - << (hardMode ? RED " [FAST] " : BLUE " [NORMAL] ") << RESET - << " \r" << std::flush; std::cout << "\r" << CLR_SCORE << "Score: " << score << CLR_RESET << " " << (hardMode ? CLR_HARD "[HARD MODE]" : CLR_NORM "[NORMAL MODE]") - << " " << std::flush; + << CLR_RESET << " " << std::flush; updateUI = false; } } From 7998505cba7b3982f0990c2e84188faa43c171ea Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 17:34:43 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Enhance=20game=20?= =?UTF-8?q?startup=20UX=20and=20fix=20CI=20failures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added "Press any key to start" prompt and 3s animated countdown - Implemented input buffer flushing to ensure a fair start - Added C++ CI workflow to test the actual project code - Fixed apisec-scan.yml and rust.yml to skip when not applicable/configured - Cleaned up color implementation and ensured proper terminal reset Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- .github/workflows/apisec-scan.yml | 1 + .github/workflows/cpp.yml | 20 ++++++++++++++++++++ .github/workflows/rust.yml | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cpp.yml diff --git a/.github/workflows/apisec-scan.yml b/.github/workflows/apisec-scan.yml index aa864c7..34ee646 100644 --- a/.github/workflows/apisec-scan.yml +++ b/.github/workflows/apisec-scan.yml @@ -48,6 +48,7 @@ permissions: jobs: Trigger_APIsec_scan: + if: ${{ secrets.apisec_username != '' && secrets.apisec_password != '' }} permissions: security-events: write # for github/codeql-action/upload-sarif to upload SARIF results actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml new file mode 100644 index 0000000..c38f523 --- /dev/null +++ b/.github/workflows/cpp.yml @@ -0,0 +1,20 @@ +name: C++ CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: make + + - name: Run Test + run: (echo ' '; sleep 5; echo 'q') | ./game | grep "Thanks for playing!" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 96b3ef2..d72dbfa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,8 +11,9 @@ env: jobs: build: - runs-on: ubuntu-latest + # Only run if there are actually Rust files to build + if: hashFiles('**/*.rs') != '' steps: - uses: actions/checkout@v4 From 302440e751e7fc2145f1ebc4263356e9788040ca Mon Sep 17 00:00:00 2001 From: aidasofialily-cmd Date: Sun, 22 Feb 2026 22:55:06 +0800 Subject: [PATCH 3/3] Potential fix for code scanning alert no. 3: Workflow does not contain permissions Potential fix for code scanning Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/cpp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index c38f523..ce5cc39 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [ "main" ] +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest