From 033f650566c1de8e898010d0a22d8b26a76e4101 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 17:32:16 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20[UX=20improvement?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added ANSI color coding for score, modes, and instructions. - Centralized UI rendering into a dedicated function for consistency. - Implemented immediate UI updates on user keypress for better tactile feedback. - Replaced sleep-based loop with reactive poll() and dynamic timeouts for efficiency and responsiveness. Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- src/main.cpp | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a70e887..039c160 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,20 @@ #include #include -#include #include #include #include +#include + +#define RESET "\033[0m" +#define B_GREEN "\033[1;32m" +#define B_RED "\033[1;31m" +#define B_BLUE "\033[1;34m" +#define B_YELLOW "\033[1;33m" + +void renderUI(int score, bool hardMode) { + std::cout << "\r" << B_GREEN << "Score: " << score << RESET + << (hardMode ? B_RED " [FAST] " : B_BLUE " [NORMAL] ") << RESET << std::flush; +} int main() { struct termios oldt, newt; @@ -13,29 +24,35 @@ int main() { tcsetattr(STDIN_FILENO, TCSANOW, &newt); int score = 0; bool hardMode = false; char input; - std::cout << "==========================\n SPEED CLICKER\n==========================\n" - << "Controls:\n [h] Toggle Hard Mode (10x Speed!)\n [q] Quit Game\n [Any key] Click!\n\n"; + std::cout << B_YELLOW << "==========================\n SPEED CLICKER\n==========================\n" + << "Controls:\n [h] Toggle Hard Mode (10x Speed!)\n [q] Quit Game\n [Any key] Click!\n\n" << RESET; struct pollfd fds[1] = {{STDIN_FILENO, POLLIN, 0}}; auto last_tick = std::chrono::steady_clock::now(); + renderUI(score, hardMode); + while (true) { - int timeout = hardMode ? 100 : 1000; - if (poll(fds, 1, 0) > 0) { - if (read(STDIN_FILENO, &input, 1) <= 0 || input == 'q') break; - if (input == 'h') { - hardMode = !hardMode; - std::cout << (hardMode ? "\n[HARD MODE] Speed x10!\n" : "\n[NORMAL MODE]\n"); - } else score++; - } + int interval = hardMode ? 100 : 1000; auto now = std::chrono::steady_clock::now(); auto elapsed = std::chrono::duration_cast(now - last_tick).count(); - if (elapsed >= timeout) { - score++; last_tick = now; - std::cout << "Score: " << score << (hardMode ? " [FAST] " : " [NORMAL] ") << "\r" << std::flush; + int remaining = std::max(0, static_cast(interval - elapsed)); + + if (poll(fds, 1, remaining) > 0) { + if (read(STDIN_FILENO, &input, 1) <= 0 || input == 'q') break; + if (input == 'h') hardMode = !hardMode; + else score++; + renderUI(score, hardMode); + } + + now = std::chrono::steady_clock::now(); + elapsed = std::chrono::duration_cast(now - last_tick).count(); + if (elapsed >= (hardMode ? 100 : 1000)) { + score++; + last_tick = now; + renderUI(score, hardMode); } - std::this_thread::sleep_for(std::chrono::milliseconds(10)); } tcsetattr(STDIN_FILENO, TCSANOW, &oldt); - std::cout << "\nFinal Score: " << score << "\nThanks for playing!\n"; + std::cout << "\n\n" << B_GREEN << "Final Score: " << score << RESET << "\nThanks for playing!\n"; return 0; } From b4170c969f52ee7e1792183c657f64de3bad5048 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 17:35:18 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20[UX=20improvement?= =?UTF-8?q?]=20and=20CI=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added ANSI color coding for score, modes, and instructions. - Centralized UI rendering for consistency. - Implemented immediate UI updates on keypress for better tactile feedback. - Replaced sleep-based loop with reactive poll() for efficiency. - Fixed misconfigured GitHub Actions workflow (switched from Rust to C++). - Added `test` target to Makefile and removed unused `Cargo.toml`. Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- .github/workflows/{rust.yml => cpp.yml} | 12 +++++------- Cargo.toml | 10 ---------- Makefile | 6 +++++- 3 files changed, 10 insertions(+), 18 deletions(-) rename .github/workflows/{rust.yml => cpp.yml} (65%) delete mode 100644 Cargo.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/cpp.yml similarity index 65% rename from .github/workflows/rust.yml rename to .github/workflows/cpp.yml index 9fd45e0..79947d6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/cpp.yml @@ -1,4 +1,4 @@ -name: Rust +name: C++ CI on: push: @@ -6,17 +6,15 @@ on: pull_request: branches: [ "main" ] -env: - CARGO_TERM_COLOR: always - jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Build - run: cargo build --verbose + run: make + - name: Run tests - run: cargo test --verbose + run: make test diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index c9a3abc..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "code" -version = "0.1.0" -edition = "2021" - -[dependencies] -# Add your dependencies here - -[dev-dependencies] -# Add your dev dependencies here diff --git a/Makefile b/Makefile index 3bf8240..95b3034 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,13 @@ $(TARGET): $(SRCS) run: $(TARGET) ./$(TARGET) +# Run tests +test: $(TARGET) + (echo "q" | ./$(TARGET)) | grep "Thanks for playing!" + # Clean up build artifacts clean: rm -f $(TARGET) # Phony targets -.PHONY: all run clean +.PHONY: all run clean test From 3fbe710c3d1c382fadb6b7fd86232c81342f1c12 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 7 Feb 2026 05:35:46 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20[UX=20improvement?= =?UTF-8?q?]=20and=20CI=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added ANSI color coding for score, modes, and instructions. - Centralized UI rendering for consistency. - Implemented immediate UI updates on keypress for better tactile feedback. - Replaced sleep-based loop with reactive poll() for efficiency. - Fixed misconfigured GitHub Actions workflow (switched from Rust to C++). - Added `test` target to Makefile and removed unused `Cargo.toml`. Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com>