Snakes and Ladders
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.
Features
- 🎲 2-4 player gameplay: Supports up to 4 players, taking turns to roll the dice.
- 🐍 Snakes and Ladders mechanics: Roll the dice, land on snakes to slide back, or climb ladders to advance.
- 🏆 Winning Condition: The first player to reach the final square (100) wins the game.
- 🎮 Interactive UI: A colorful, grid-based visual game board with player positions, snakes, and ladders.
- 📜 Player status messages: Get real-time updates about your dice roll, movement, and interactions with snakes and ladders.
- 🔄 Player reset: If a player lands on the same position as another, the other player is sent back to the start.
Installation
Install the binary
To install the Snakes and Ladders game globally as a command-line binary, run:
Once installed, you can run the game directly from the terminal.
Install as a library
To use the Snakes and Ladders game as a library in your own project, run the following command in your project directory:
Or, manually add it to your Cargo.toml file:
[]
= "1.0.0"
Running the Game
After installing the binary with cargo install, you can run the game using:
This will launch the Snakes and Ladders game with a graphical user interface (GUI).
Customization
You can customize the game by modifying the board size and the positions of snakes and ladders.
Example of Customizing 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 Game;
use HashMap;
In the above code:
- Snakes: If a player lands on a snake's head (e.g., 16), they will move to its tail (e.g., 6).
- Ladders: If a player lands at the bottom of a ladder (e.g., 1), they will climb up to the top (e.g., 38).