GithubHelp home page GithubHelp logo

wasm-peers / footballers Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 296 KB

2D real-time mutliplayer game in a browser. Example usage of wasm-peers library.

License: Apache License 2.0

Rust 99.08% HTML 0.45% CSS 0.47%
rust game webassembly haxball webrtc

footballers's Introduction

Footballers

footballers game

Description

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.

Functionality

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.

Local development

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.

Roadmap

  • Allow game restart after it ends
  • Remove disconnected players from the game
  • Move JavaScript code to Rust

Authors

Arkadiusz Górecki
LinkedIn

Tomasz Karwowski
LinkedIn

License

This project is licensed under either of

Contribution

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.