{"id":51011482,"url":"https://github.com/xsa-dev/snake_macroquad","last_synced_at":"2026-06-21T03:03:43.702Z","repository":{"id":313555019,"uuid":"1051827842","full_name":"xsa-dev/snake_macroquad","owner":"xsa-dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-03T21:31:44.000Z","size":668,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-03T23:21:48.732Z","etag":null,"topics":["demo","macroquad","rust","snake"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xsa-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-06T19:59:32.000Z","updated_at":"2025-11-03T21:31:47.000Z","dependencies_parsed_at":"2025-09-06T22:14:23.985Z","dependency_job_id":"279974a8-2c2d-47fc-9277-d0d5f4523193","html_url":"https://github.com/xsa-dev/snake_macroquad","commit_stats":null,"previous_names":["xsa-dev/snake_macroquad"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xsa-dev/snake_macroquad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsa-dev%2Fsnake_macroquad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsa-dev%2Fsnake_macroquad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsa-dev%2Fsnake_macroquad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsa-dev%2Fsnake_macroquad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xsa-dev","download_url":"https://codeload.github.com/xsa-dev/snake_macroquad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xsa-dev%2Fsnake_macroquad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34592058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","macroquad","rust","snake"],"created_at":"2026-06-21T03:03:43.009Z","updated_at":"2026-06-21T03:03:43.696Z","avatar_url":"https://github.com/xsa-dev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snake - Matrix Style\n\nA retro-style Snake game built with Rust and Macroquad, featuring a Matrix-inspired aesthetic with procedural map generation and dynamic gameplay.\n\n![Game Over Screen](img/game_over2.png)\n\n## Features\n\n### 🎮 Core Gameplay\n- **Classic Snake mechanics** with smooth movement and collision detection\n- **Procedural map generation** with configurable wall density\n- **Configurable game speed** for different difficulty levels\n- **Score tracking** with persistent best score storage\n\n### 🎨 Visual Design\n- **Matrix-inspired aesthetic** with green color palette\n- **Dynamic glyph rendering** using Matrix-style characters (0, 1, \u003c, \u003e, [, ], etc.)\n- **Animated Matrix rain background** for immersive atmosphere\n- **Responsive scaling** that adapts to different screen sizes\n- **Fullscreen mode** with high DPI support for immersive gameplay\n- **Adaptive UI** with centered text and dynamic scaling for all screen resolutions\n- **Map preview in lobby** with animated snake demo showing current difficulty settings\n\n### 🔊 Audio\n- **Procedurally generated sound effects** using WAV synthesis\n- **Eat sound** (880Hz tone) when consuming food\n- **Death sound** (110Hz tone) when game ends\n- **Adjustable volume** with dedicated settings screen\n- **Persistent volume settings** saved across game sessions\n\n### 💾 Data Persistence\n- **Save system** using JSON for game settings and high scores\n- **Persistent configuration** of last used seed, wall density, and speed\n- **Best score tracking** across game sessions\n- **Sound volume persistence** with automatic restoration on launch\n\n## Controls\n\n### Global\n- **Q** - Quit the game (from any screen)\n\n### In-Game\n- **Arrow Keys** or **WASD** - Move the snake\n- **R** - Restart game (when game over)\n\n### In Lobby\n- **Enter** - Start new game (when \"Start\" is selected)\n- **↑ / ↓** - Navigate menu items\n- **← / →** - Adjust selected setting (wall density or speed)\n- **R** - Generate new random seed\n- **- / +** - Decrease/Increase wall density (0-35%)\n- **[ / ]** - Decrease/Increase game speed (50-350ms)\n- **S** - Open settings screen\n\n### In Settings\n- **← / →** or **- / +** - Adjust sound volume (0-100%)\n- **M** - Toggle mute/unmute\n- **Enter** or **Esc** - Return to lobby\n\n### Game Over\n- **R** - Restart game with same settings\n- **Enter** - Return to lobby\n- **Q** - Quit game\n\n## Technical Details\n\n### Architecture\n- **State-based design** with four main screens: Lobby, Settings, Playing, GameOver\n- **Modular components** for map generation, snake logic, and rendering\n- **Efficient collision detection** using HashSet for wall positions\n- **Deterministic map generation** using seeded random number generation\n- **Dynamic screen management** with smooth transitions between states\n- **Adaptive rendering** using screen dimensions for multi-resolution support\n\n### Performance\n- **60 FPS target** with smooth frame timing\n- **Efficient rendering** with glyph-based graphics\n- **Memory-efficient** data structures for game state\n\n### Dependencies\n- **macroquad 0.4** - Cross-platform game framework\n- **serde** - Serialization for save data\n- **serde_json** - JSON format support\n\n## Installation \u0026 Running\n\n### Prerequisites\n- Rust 1.70+ with Cargo\n- OpenGL 3.3+ compatible graphics card\n\n### Build \u0026 Run\n```bash\n# Clone the repository\ngit clone \u003crepository-url\u003e\ncd snake_macroquad\n\n# Run the game\ncargo run --release\n```\n\n### Development\n```bash\n# Run in debug mode\ncargo run\n\n# Build for release\ncargo build --release\n```\n\n## Game Configuration\n\n### Map Generation\n- **Seed-based generation** ensures reproducible maps\n- **Wall density** controls difficulty (0-35% of cells)\n- **Safe spawn area** prevents immediate collision\n\n### Gameplay Settings\n- **Move interval** controls snake speed (50-350ms)\n- **Grid size** is fixed at 32x24 tiles\n- **Tile size** scales with screen resolution\n- **Sound volume** adjustable from 0-100% (persisted across sessions)\n\n### Display Settings\n- **Fullscreen mode** enabled by default\n- **High DPI support** for crisp rendering on high-resolution displays\n- **Adaptive scaling** ensures proper display on any screen size\n\n## File Structure\n\n```\nsnake_macroquad/\n├── src/\n│   └── main.rs          # Main game logic and rendering\n├── img/\n│   └── game_over.png    # Screenshot for documentation\n├── Cargo.toml           # Project dependencies\n├── Cargo.lock           # Dependency lock file\n├── snake_save.json      # Persistent save data (auto-generated)\n├── CHANGELOG.md         # Project changelog\n└── README.md            # This file\n```\n\n## Code Highlights\n\n### Matrix Glyph System\n```rust\nconst MATRIX_GLYPHS: \u0026[u8] = b\"01\u003c\u003e[]{}()/\\\\|-=+*;:.,^~ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\nfn matrix_char_for_cell(c: Cell) -\u003e char {\n    let hx = (c.x as i64).wrapping_mul(73_856_093);\n    let hy = (c.y as i64).wrapping_mul(19_349_663);\n    let h = (hx ^ hy).unsigned_abs() as usize;\n    MATRIX_GLYPHS[h % MATRIX_GLYPHS.len()] as char\n}\n```\n\n### Procedural Map Generation\n```rust\nfn generate(seed: u64, wall_density: f32) -\u003e Self {\n    macroquad::rand::srand(seed);\n    // Generate border walls and random interior walls\n    // Ensure safe spawn area around center\n}\n```\n\n### Sound Generation\n```rust\nfn generate_wav_sine(frequency_hz: f32, duration_seconds: f32, volume: f32) -\u003e Vec\u003cu8\u003e {\n    // Generate WAV file data for simple sine wave tones\n}\n```\n\n## Contributing\n\nFeel free to submit issues, feature requests, or pull requests to improve the game!\n\n## License\n\nThis project is open source. Feel free to use and modify as needed.\n\n---\n\n*Built with ❤️ using Rust and Macroquad*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxsa-dev%2Fsnake_macroquad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxsa-dev%2Fsnake_macroquad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxsa-dev%2Fsnake_macroquad/lists"}