diff --git a/.Jules/palette.md b/.Jules/palette.md index 8aed79d..a7161b4 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. + +## 2024-11-20 - Game Start Flow and User Preparation +**Learning:** Transitioning directly from a menu/instructions screen to active gameplay in time-sensitive games can be jarring. A "Press any key to start" followed by a clear, animated countdown (3-2-1-GO) provides a necessary buffer for the user to reposition their hands and focus. Using `tcflush` after the countdown ensures a fair start by discarding accidental inputs during the wait. +**Action:** Implement a preparation phase (start prompt + countdown) for any interactive CLI game or tool that requires rapid user response. diff --git a/.github/workflows/apisec-scan.yml b/.github/workflows/apisec-scan.yml deleted file mode 100644 index aa864c7..0000000 --- a/.github/workflows/apisec-scan.yml +++ /dev/null @@ -1,71 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# APIsec addresses the critical need to secure APIs before they reach production. -# APIsec provides the industry’s only automated and continuous API testing platform that uncovers security vulnerabilities and logic flaws in APIs. -# Clients rely on APIsec to evaluate every update and release, ensuring that no APIs go to production with vulnerabilities. - -# How to Get Started with APIsec.ai -# 1. Schedule a demo at https://www.apisec.ai/request-a-demo . -# -# 2. Register your account at https://cloud.apisec.ai/#/signup . -# -# 3. Register your API . See the video (https://www.youtube.com/watch?v=MK3Xo9Dbvac) to get up and running with APIsec quickly. -# -# 4. Get GitHub Actions scan attributes from APIsec Project -> Configurations -> Integrations -> CI-CD -> GitHub Actions -# -# apisec-run-scan -# -# This action triggers the on-demand scans for projects registered in APIsec. -# If your GitHub account allows code scanning alerts, you can then upload the sarif file generated by this action to show the scan findings. -# Else you can view the scan results from the project home page in APIsec Platform. -# The link to view the scan results is also displayed on the console on successful completion of action. - -# This is a starter workflow to help you get started with APIsec-Scan Actions - -name: APIsec - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the "main" branch - # Customize trigger events based on your DevSecOps processes. - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - schedule: - - cron: '24 23 * * 6' - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - - -permissions: - contents: read - -jobs: - - Trigger_APIsec_scan: - 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 - runs-on: ubuntu-latest - - steps: - - name: APIsec scan - uses: apisec-inc/apisec-run-scan@025432089674a28ba8fb55f8ab06c10215e772ea - with: - # The APIsec username with which the scans will be executed - apisec-username: ${{ secrets.apisec_username }} - # The Password of the APIsec user with which the scans will be executed - apisec-password: ${{ secrets.apisec_password}} - # The name of the project for security scan - apisec-project: "VAmPI" - # The name of the sarif format result file The file is written only if this property is provided. - sarif-result-file: "apisec-results.sarif" - - name: Import results - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ./apisec-results.sarif diff --git a/.github/workflows/rust.yml b/.github/workflows/cpp.yml similarity index 52% rename from .github/workflows/rust.yml rename to .github/workflows/cpp.yml index 96b3ef2..95317d1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/cpp.yml @@ -1,4 +1,4 @@ -name: Rust +name: C++ CI on: push: @@ -6,20 +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 - - name: Run tests - run: cargo test --verbose + run: make - permissions: - contents: read + - name: Verify + run: (echo ' '; sleep 4; echo 'q') | ./game | grep "Thanks for playing!" 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/src/main.cpp b/src/main.cpp index 1b74c74..d116e6c 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,22 @@ 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; + if (read(STDIN_FILENO, &input, 1) <= 0 || input == 'q') { + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + return 0; + } + + 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 << "\n" << std::flush; + tcflush(STDIN_FILENO, TCIFLUSH); struct pollfd fds[1] = {{STDIN_FILENO, POLLIN, 0}}; auto last_tick = std::chrono::steady_clock::now(); @@ -46,9 +62,6 @@ 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;