A 2-player fighting game written in Rust with the Bevy game engine. Based on JavaScript Fighting Game Tutorial with HTML Canvas
Assets:
- Oak Woods Assets
- Fighter Asset #1
- Fighter Asset #2
- m6x11 a 6px by 11px font by Daniel Linssen
- Melee sounds
- Boss Battle #6 Metal
- Adventure Intro Title
This project uses Cargo workspaces and split into 2 library and one binary:
Notes:
- A clean build will take a long time due to compilation of the entire
bevy
engine. - The assets folder in the root of the project is symlinked into the
desktop
project. - The assets folder needs to be copied to
destop
andbrowser/www
folders. It is ignored in.gitignore
for this reason.
This is the shared library that houses the core game logic. It will be built as part of the other projects which target different platforms such as desktop and WebAssembly.
This compiles a desktop binary for the game.
cargo build -p desktop
To build release version:
cargo build -p desktop --release
This is for the WebAssembly game and uses wasm-pack. It can't be build form the workspace root so you have to change to the project folder first.
NOTE: This relies on Node 16.13.0 LTS
.
The following will build with --release
by default:
cd browser
wasm-pack build --out-dir pkg
The following steps are for the first time setup only,
Initialize the Node application:
npm init wasm-app www
Install dependencies for Node application:
cd www
npm install
Update browser/www/package.json
:
{
// ..
"scripts": {
// ...
"start": "cp -r ../../assets ./ && webpack-dev-server" // Update this line!
// ...
},
// ...
"devDependencies": {
"browser": "file:../pkg", // Add this line!
// ...
}
// ...
}
Update browser/www/index.js
:
import * as wasm from "browser";
wasm.run()
Install dependencies again:
cd www
npm install
cp -r assets desktop/assets
cargo run -p desktop
cd browser/www
npm run start
If you are using a newer verison of Node, then you might need to add NODE_OPTIONS
like this:
cd browser/www
NODE_OPTIONS=--openssl-legacy-provider npm run start
Open the browser to the http://localhost:8080.
NOTES:
By default browsers block autoplay and so there might be no sound.
Firefox:
- Under
Tools
menu clickPage Info
. - Click
Permissions
tab. - Under
Autoplay
uncheckUse Default
- Check
Allow Audio and Video
.
Safari:
- Go to
Preferences
. - Click
Websites
tab. - On the left side click
Auto-Play
- Enable
Allow All Auto-Play
forlocalhost
.
Chrome:
- Go to
Settings
. - On the left select
Privacy and security
. - Scroll down to
Additional content settings
. - Click
Sounds
- Under
Allowed to play sound
addlocalhost
.