Expand description
§Snake Game using Ratatui
This module implements a terminal-based snake game using the Ratatui crate for rendering.
§Features
- Terminal UI: Uses Ratatui for rendering a grid-based game.
- Game Logic: Manages snake movement, collisions, and scoring.
- Multithreading: Uses multiple threads for input handling, rendering at 60 FPS, and game logic execution.
- Emoji-based graphics: Supports rendering the snake using emojis instead of ASCII.
- Configurable parameters: With
clap
for command-line arguments.
§TODO
- Add a save score (local db) with a pseudo got from cmdline
- Add some performance log with tracing for example
- Fix too much life display outside of screen
§References
- Clippy lints: https://github.com/rust-lang/rust-clippy/
- Ratatui tutorial: https://ratatui.rs/tutorials/hello-world/
- Example: https://ratatui.rs/examples/widgets/canvas/
§Architecture
- Uses
RwLock
for synchronization. - Spawns separate threads for input handling, rendering (60Hz), and game logic execution.
§Documentation generation
cargo doc --document-private-items --no-deps --open
§Tests
- As usual run them with
cargo test
the project is set up with a lib containing all the code, and a main.rs just calling it - As this is a widespread pattern providing full compliance with the Rust test ecosystem, allowing doc comment to be automatically tested, for example.
Modules§
- controls
- Game Control Modules
- game_
logic - Game logic Modules
- graphics
- Game graphical Modules
Functions§
- start_
snake - Panics