https://github.com/joamag/battlerust
A Battleship game implementation in Rust 🦀
https://github.com/joamag/battlerust
battleship game rust wasm
Last synced: 13 days ago
JSON representation
A Battleship game implementation in Rust 🦀
- Host: GitHub
- URL: https://github.com/joamag/battlerust
- Owner: joamag
- License: apache-2.0
- Created: 2022-12-06T08:31:22.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-18T23:28:42.000Z (about 1 month ago)
- Last Synced: 2025-04-14T10:13:20.536Z (13 days ago)
- Topics: battleship, game, rust, wasm
- Language: Rust
- Homepage:
- Size: 203 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [Battlerust 🦀 + 🛥️](https://battlerust.joao.me)
A Battleship game implementation in Rust 🦀.
## Challenge
Create an application to allow a single human player to play a one-sided game of Battleships against ships placed by the computer.
The program should create a 10x10 grid, and place a number of ships on the grid at random with the following sizes:
* 1x Battleship (5 squares)
* 2x Destroyers (4 squares)The player enters coordinates of the form “A5”, where "A" is the column and "5" is the row, to specify a square to target. Shots result in hits, misses or sinks. The game ends when all ships are sunk.
## Deployments
| Provider | Stable | URL |
| ---------- | ------- | ------------------------------------------------------------------ |
| Cloudflare | `True` | [battlerust.joao.me](https://battlerust.joao.me) |
| Cloudflare | `True` | [battlerust.pages.dev](https://battlerust.pages.dev) |
| Cloudflare | `False` | [master.battlerust.pages.dev](https://master.battlerust.pages.dev) |## Build & Run
### Native
```bash
cd frontends/console
cargo build
cargo run
```### WASM for Web
```bash
cargo install wasm-pack
wasm-pack build --release --target=web --out-dir=frontends/web/lib -- --features wasm
cd frontends/web
npm install && npm run build
cd dist && python3 -m http.server
```### WASM with WASI
```bash
rustup target add wasm32-wasi
cd frontends/console
cargo build --release --target wasm32-wasi
cd ../../target/wasm32-wasi/release
wasmtime battlerust-console.wasm
```### Raspberry Pi (with Linux)
```bash
apt install gcc-arm-linux-gnueabihf
rustup target add armv7-unknown-linux-gnueabihf
cd frontends/console
cargo build --release --target armv7-unknown-linux-gnueabihf --config target.armv7-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-gcc\"
```## WASM Console
You can use [WebAssembly.sh](https://webassembly.sh) to play around with the [WASI](https://wasi.dev/) compliant [WASM](https://webassembly.org/) assembly and interact with this Web shell in the same way as you would in your normal OS shell.
In alternative you can use the [Wasmtime](https://wasmtime.dev) WASM runtime to run the WASM binary in your local computer.
## Build Automation
[](https://github.com/joamag/battlerust/actions)
[](https://crates.io/crates/battlerust)
[](https://www.npmjs.com/package/battlerust)
[](https://www.apache.org/licenses/)