2D real-time multiplayer game in a browser. Players divided in two teams play a football match on field with two goal posts. Goal of the game is for a team to score 3 points before the other team.
This game showcases the usability of wasm-peers crate for easy and costless peer-2-peer WebRTC communication.
Check the hosted game here.
Game supports any number of players, but at least 2 are necessary to start the game. Players connect by providing session id received by some means from the game host. This host is responsible for receiving players input, calculating game state and sending updated state to all connected players.
On the field, players can collide with each other and the ball, they can shoot the ball if they are close enough. If one of the teams scores a goal, by bringing the ball across the goal posts, the score is updated and the game is reset.
To run the game locally you must have Rust and trunk installed.
Signaling server from wasm-peer project should be running on 0.0.0.0:9001
.
See here for instructions.
For now, only env variable without the default is the signaling server address in production, it should be some publicly available server, for ex. EC2 instance (tiny one should suffice).
You can run the project:
SIGNALING_SERVER_URL="ws://0.0.0.0:9001" trunk serve # comes with awesome hot-reloading
If you only want to build the static files:
SIGNALING_SERVER_URL="ws://0.0.0.0:9001" trunk build
This will create a dist
folder with index.html
and all the other required files.
You can serve them any way you like.
- Allow game restart after it ends
- Remove disconnected players from the game
- Move JavaScript code to Rust
Arkadiusz Górecki
LinkedIn
Tomasz Karwowski
LinkedIn
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.