Hey! Amir here! ๐
First of all: Thank you so much for the incredible interaction I had had when I shared my Rust Full Course for Beginners last month.
I'm glad to know that it was helpful to you, even if just a bit.
Every opportunity to provide value and help you learn is something I cherish deeply.
I'll always be ready to support your learning journey, guys.
Today, Iโm super excited to share my latest project with you all: a classic Battleship game implemented in Rust.
This isnโt just a throwback to those childhood days of sinking ships on graph paper, but also a neat little journey through the awesomeness of Rust's standard library for I/O handling and random number generation.
So, let me show you what I have for you today, and maybe even contribute to this Battleship game.
Features
Let's kick things off by highlighting some cool features of our Battleship game:
- Random Ship Placement: Ships are placed randomly ensuring no overlaps or out-of-bounds positioning.
- User Input: You can fire at coordinates through basic user input.
- Game Board Display: The game board displays hits, misses, and ships using different symbols.
- Simple Game Loop: The game runs in a turn-based loop.
- Game Over Detection: It checks for game over conditions, so you know when you've won (or lost)! # Installation First things first, you need to have Rust installed. If you havenโt got it yet, head over to rust-lang.org and get it.
Once Rust is all set up, cloning the repository is your next step. Hereโs how you do it:
git clone https://github.com/BekBrace/rust-bship-game.git
cd battleship-rust
cargo build
cargo run
Here's the game tutorial if you prefer to watch it :-)
Game Rules
For those who need a quick refresher on how Battleship works, here are the basics:
- Each player has a 10x10 board.
- Ships of different sizes (5, 4, 3, 3, 2) are randomly placed on the board.
- Players take turns firing at each otherโs boards by entering coordinates.
- Hits are marked with a red dot (โ), and misses with a blue dot (ยท).
- The game continues until all ships of one player are sunk.
And there you have it, folks! A full Battleship CLI game in Rust.
Whether you're a Rustacean or just someone looking to play a fun game, I hope this project brings you as much joy as it brought me creating it.
Stay safe, happy coding, and may the best captain win :-)
Catch you next time,
Amir ๐
Top comments (2)
great voice and good video
Cheers