This is a port of shooter-rust to WebAssembly.
Try it now in your browser! https://msakuta.github.io/shooter-rust-wasm/
- Arrow keys, W, A, S, D - move
- Z, X - select weapon
- Space - shoot weapon
- P - toggle pause game
- N - Restart new game
This game uses JavaScript and WebAssembly (Wasm), so you need a browser with WebAssembly support. Most modern browser support it nowadays.
Install
- Cargo >1.40
- npm >7.0.2
Install npm packages
npm i
npm start
It will start webpack-dev-server, launch a browser and show http://localhost:8080 automatically.
npm run build
There is also native application version implemented with Piston game engine
that can be compiled in a sub-crate shooter-rust-native
.
Below is a screenshot on Windows.
Honestly I wouldn't much like to keep the native version, because Wasm is more portable, fast to compile and even looks faster to run. But I will keep it anyway as an exercise making portable application among native and the web.
It should support all platforms that Piston supports, which is basically desktops, like Windows, Linux or Mac.
Install
- Cargo >1.40
Run
cd shooter-rust-native
cargo run --release
Note that cargo run --release --package shooter-rust-native
won't work, because the root crate assumes
different feature set than native version.
The root crate uses "webgl" feature, which will enable wasm-bindgen and generating Wasm interface,
which is not compatible with native version.
I originally wrote this game in C back in 2007 with Windows API.
About a decade later, I re-implmented it in Rust and Piston.
Now finally I could bring it to the web without converting the codebase into JavaScript or TypeScript.
- wasm-bindgen
I use WebGL API directly, without any graphics libraries.