| Crates.io | snake_ladder |
| lib.rs | snake_ladder |
| version | 1.0.0 |
| created_at | 2024-11-26 06:04:40.753372+00 |
| updated_at | 2025-01-10 12:11:57.344166+00 |
| description | A graphical implementation of the classic Snakes and Ladders game in Rust, featuring multiplayer support, interactive UI, and customizable snakes and ladders positions. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1461233 |
| size | 108,121 |
A graphical implementation of the classic Snakes and Ladders game written in Rust. Play with 2-4 players and enjoy the excitement of rolling dice, climbing ladders, and avoiding snakes as you race to the finish!
This game uses the eframe and egui libraries for a graphical user interface (GUI) and is available as a crate on crates.io.
To install the Snakes and Ladders game globally as a command-line binary, run:
cargo install snake_ladder
Once installed, you can run the game directly from the terminal.
To use the Snakes and Ladders game as a library in your own project, run the following command in your project directory:
cargo add snake_ladder
Or, manually add it to your Cargo.toml file:
[dependencies]
snake_ladder = "1.0.0"
After installing the binary with cargo install, you can run the game using:
snake_ladder
This will launch the Snakes and Ladders game with a graphical user interface (GUI).
You can customize the game by modifying the board size and the positions of snakes and ladders.
You can modify the snakes and ladders positions by passing new values in the main.rs file where the game is initialized. Here's an example:
use snake_ladder::Game;
use std::collections::HashMap;
fn main() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions::default();
// Custom Snakes and Ladders positions
let snakes = HashMap::from([
(16, 6), // Snake from 16 to 6
(47, 26), // Snake from 47 to 26
(49, 11), // Snake from 49 to 11
(56, 53), // Snake from 56 to 53
(62, 19), // Snake from 62 to 19
(64, 60), // Snake from 64 to 60
(87, 24), // Snake from 87 to 24
(93, 73), // Snake from 93 to 73
(95, 75), // Snake from 95 to 75
(98, 78), // Snake from 98 to 78
]);
let ladders = HashMap::from([
(1, 38), // Ladder from 1 to 38
(4, 14), // Ladder from 4 to 14
(9, 31), // Ladder from 9 to 31
(21, 42), // Ladder from 21 to 42
(28, 84), // Ladder from 28 to 84
(36, 44), // Ladder from 36 to 44
(51, 67), // Ladder from 51 to 67
(71, 91), // Ladder from 71 to 91
(80, 100), // Ladder from 80 to 100
]);
// Running the game with the custom snakes and ladders
eframe::run_native(
"Snakes and Ladders",
options,
Box::new(|_cc| Ok(Box::new(Game::new(snakes, ladders)))),
)
}
In the above code: