| Crates.io | maze_runner_rs |
| lib.rs | maze_runner_rs |
| version | 0.2.0 |
| created_at | 2025-03-31 15:54:29.822934+00 |
| updated_at | 2025-04-12 09:16:38.583767+00 |
| description | A simple text-based maze game library |
| homepage | |
| repository | https://github.com/enumura1/maze_runner_rs |
| max_upload_size | |
| id | 1613561 |
| size | 22,414 |
A simple Rust library for creating and playing text-based maze games. The maze is procedurally generated, and the player must find their way from the entrance to the exit.
Add this to your Cargo.toml:
[dependencies]
maze_game = "0.1.0"
use maze_game::maze::Maze;
fn main() {
// Create a new maze with default size (17x11)
let mut maze = match Maze::new() {
Some(m) => m,
None => {
println!("Failed to generate the maze.");
return;
}
};
// Or create a maze with custom size (width, height)
let mut custom_maze = match Maze::with_size(25, 15) {
Some(m) => m,
None => {
println!("Failed to generate the maze.");
return;
}
};
// Display the maze
println!("{}", maze.get_maze_as_string());
// Try to move the player, Move right
let moved = maze.move_player("d");
// Check if the game is completed
let state = maze.get_state();
if state.is_completed {
println!("Congratulations! You've reached the goal!");
}
}
Execute the following command to run the standalone game with default size (17x11):
cargo run
To specify custom maze dimensions:
cargo run -- 25 15
Where 25 is the width and 15 is the height.
w or up: Move ups or down: Move downa or left: Move leftd or right: Move rightq: Quit the gamelib.rs: Public module exportsmain.rs: Standalone game loop and user input handlingmaze.rs: Maze data structure and operationsgenerator.rs: Maze generation algorithmsposition.rs: Position structureThis project is licensed under the MIT License - see the LICENSE file for details.