Code Monkey home page Code Monkey logo

laniakea's Introduction

Laniakea

An experimental multiplayer game engine for browsers.

Status: Unstable, under development.

Motivation (for Yet Another Javascript Game Engine)

There are many game engines that target browsers these days. To give just a few examples:

The support for multiplayer with a browser client offered by most established engines, ranges from "severely limited" to "non-existent". Relatedly, certain kinds of games โ€” or game mechanics โ€” are typically problematic or avoided entirely in a browser-based game, due to the Head-of-line blocking that comes with HTTP/WebSocket-based communication. It's likely that these engines have not been able to ship a networking solution for the browser that would be on par with other platforms that have access to unordered, unreliable networking layers.

Given the potential of WebRTC DataChannels to fulfill a similar role to UDP in traditional Game Engine architecture, and support for WebRTC being relatively widespread, I thought it would be interesting to explore whether WebRTC could improve this situation.

In this insightful article the game networking veteran Glenn Fiedler specifically criticises WebRTC as "extremely complex", stemming from its focus on peer-to-peer networking, and states that:

game developers appreciate simplicity and desire a "WebSockets for UDP"-like approach over the complexity of WebRTC

He goes on to propose a new UDP-based protocol netcode.io with a view to it perhaps being accepted in to browser implementations.

While I entirely agree with Glenn on WebRTC having a lot of baggage beyond what is required for an unreliable channel between a game client and server, I wish to examine whether its possible create a system on top of WebRTC, that hides enough of that complexity, and allows us to build and deploy browser games that can get the advantages of this unreliable data channel and works in browser implementations today, rather than introducing a new standard and waiting for another round of browser standardisation and implementation.

In order to prove that a game networking solution is effective for development and deployment, it is prudent to actually use it in a few example games that benefit from the networking solution. To support building these examples, I'm implementing a full runtime for organising game state and simulation, named Laniakea, in addition to the networking subsystem. Thus this codebase is a "game engine" rather than just a "game networking library".

Games shall implement their state and their logic in terms of this runtime, and as a result, will get out-of-the-box state replication between server and client. Games will be able to control networking where it intersects with things like "visibility" in a game, in order to achieve both security and performance objectives. Laniakea will provide a more "bring your own" approach to everything outside of State, Simulation, and Networking.

Key Features

  • Statically typed. Built with TypeScript.
  • Game state replication over webRTC Data Channels. Avoids Head-of-line blocking.

Demo

Assuming you have node v10.15.3 and yarn v1.16.0 installed. To see the demo:

yarn run bootstrap
yarn run build
# See it run
yarn run demo

While it's running open http://127.0.0.1:8080 to see the demo. Try opening 2 browser tabs!

Learn More

Perhaps check out the demo n-player pong implementation, or check out the API docs.

Development Notes

This is a monorepo of multiple npm packages managed using lerna, and yarn's workspaces feature. We'll assume you have node and yarn installed. I'm using node v14.16.0 and yarn 1.22.10 in case it matters.

Formatting

yarn run prettier:write

Linting

yarn run lint:fix

Build docs

yarn run typedoc

Going Nuclear with package upgrades

yarn run lerna exec --concurrency 1 "yarn upgrade --latest"
yarn upgrade --latest
# If the above doesn't seem to update everything, this might work better:
yarn upgrade-interactive --latest

laniakea's People

Contributors

efokschaner avatar

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.