@aamathews23/battleship-web
v3.0.1
Published
The game of battleship, implemented in Rust, compiled to WASM, and distributed in JS / TS.
Maintainers
Readme
battleship_web
This is a WASM library for the Battleship game.
Usage
Install the package:
npm install @aamathews23/battleship-webInitialize WASM and start the game:
import init, {
build_board,
shoot_ship,
is_end_of_game,
} from '@aamathews23/battleship-web';
init().then((wasm) => {
const board = build_board();
const result = shoot_ship(3, 5);
if (result === 1) {
console.log('Hit!');
} else if (result === 2) {
console.log('Miss!');
} else {
console.log('Already shot here!');
}
if (is_end_of_game()) {
console.log('Game Over!');
}
});