Battleship Game in RUST

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 valu…


This content originally appeared on DEV Community and was authored by Bek Brace

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:

  1. Random Ship Placement: Ships are placed randomly ensuring no overlaps or out-of-bounds positioning.
  2. User Input: You can fire at coordinates through basic user input.
  3. Game Board Display: The game board displays hits, misses, and ships using different symbols.
  4. Simple Game Loop: The game runs in a turn-based loop.
  5. 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.

Image description

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 🚀


This content originally appeared on DEV Community and was authored by Bek Brace


Print Share Comment Cite Upload Translate Updates
APA

Bek Brace | Sciencx (2024-06-23T20:03:38+00:00) Battleship Game in RUST. Retrieved from https://www.scien.cx/2024/06/23/battleship-game-in-rust/

MLA
" » Battleship Game in RUST." Bek Brace | Sciencx - Sunday June 23, 2024, https://www.scien.cx/2024/06/23/battleship-game-in-rust/
HARVARD
Bek Brace | Sciencx Sunday June 23, 2024 » Battleship Game in RUST., viewed ,<https://www.scien.cx/2024/06/23/battleship-game-in-rust/>
VANCOUVER
Bek Brace | Sciencx - » Battleship Game in RUST. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/23/battleship-game-in-rust/
CHICAGO
" » Battleship Game in RUST." Bek Brace | Sciencx - Accessed . https://www.scien.cx/2024/06/23/battleship-game-in-rust/
IEEE
" » Battleship Game in RUST." Bek Brace | Sciencx [Online]. Available: https://www.scien.cx/2024/06/23/battleship-game-in-rust/. [Accessed: ]
rf:citation
» Battleship Game in RUST | Bek Brace | Sciencx | https://www.scien.cx/2024/06/23/battleship-game-in-rust/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.