A Rust library for creating terminal-based platformer games with physics-based movement and obstacle avoidance.
- Physics-based bird movement with gravity and jumping mechanics
- Procedurally generated obstacles with random properties
- Level progression system with increasing difficulty
- Collision detection
- Terminal-based rendering using crossterm
- Customizable game parameters
- Rust 1.70 or higher
- A terminal that supports ANSI escape codes
Add this to your Cargo.toml:
[dependencies]
game_lib = { path = "path/to/game_lib" }use game_lib::{animation::Animation, game::GameSession};
fn main() -> std::io::Result<()> {
let screen_size = (80, 24);
let mut game_session = GameSession::new();
game_session.init_terminal()?;
game_session.start();
let mut animation = Animation::new(screen_size, game_session.get_level());
while game_session.is_running() {
animation.update(&mut game_session);
// Handle input, drawing, etc.
}
game_session.cleanup_terminal()?;
Ok(())
}To run the included example game:
cargo run -p platform-rsControls:
- Space: Make the bird jump
- R: Restart game (when game over)
- ESC: Quit game
Run the test suite:
cargo testThis includes both unit tests and integration tests that verify the game mechanics work correctly.
Generate and view the documentation:
cargo doc --lib --no-deps --opengame_lib/- The core game librarysrc/animation.rs- Game state and animation managementbird.rs- Player character physics and renderinggame.rs- Game session and state managementrect.rs- Obstacle generation and management
examples/- Example implementationstests/- Integration tests
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.