Skip to content

A boilerplate for making online multiplayer games with godot engine and node.js

License

Notifications You must be signed in to change notification settings

AnicetNgrt/GodotOnlineRoomSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot

What is it ?

This is a template you can start any (non AAA) multiplayer project from.

It implements the very popular game room and secret code connection system. Which you certainly have already experienced in games such as Among Us or Agar.io.

This is based on Node.js, an insanely popular javascript runtime for backend software (webservers, real-time game servers, APIs...). Although making game servers with Node.js is not very memory efficient, unlike the traditionnal way of doing which involves C or C++ (or even Rust nowadays), developping with it is very easy and fast. It is super appropriate for making Minimum Viable Products. Just avoid having AAA trafic and advanced security concerns.

For the frontend it is plain Godot Engine and GdScript. It connects to the server via WebSockets.

Supported platforms

The frontend was tested on several platforms, feel free to give us your results.

  • HTML5 Firefox
  • Linux Ubuntu
  • Windows 10

Other platforms are probably fine too. But you'll have to test them by yourself.

How it works

The system

In this room system a client (or frontent) (the player's version of the software) connects via a networking protocol to a server (a private and confidential software, which is part of the backend).

The client declares itself with a name the player has chosen through the game's UI, and the server then accepts the connection and assigns an ID to the client.

Then the player is prompted with two choices: create a game (or room) or join a game (or room).

When a player chooses to create a game, the room's code is given to it by the server. The player can then give it to the other players for them to join with.

When a player chooses to connect, it has to enter the room's code.

When someone joins or leaves a room, all the guests are notified.

When the room has no guests anymore, it is automatically deleted.

When all guests declare themselves as ready, the game starts.

Once a game is started, no one can join it anymore.

Architecture and stack

Archi

How to launch

Running the server on localhost

  1. Open a terminal
  2. Clone this code
  3. Install NPM & Node.js
  4. Go to backend/server/ dir
  5. npm install to install all the dependencies
  6. Create a file called .env in the root folder
  7. Write PORT=3001 inside it and save
  8. Now npm start

Running the client

  1. Open Godot project manager
  2. Scan for projects in frontend/
  3. Open the project and run

Deploying the server

There are many many easy and complicated ways of hosting a Node.js server.

If you don't have time and money to kill, you can use Heroku. The free plan lets you host your project 24/7 for the first 21st days of the month (its complicated, fact check this).

Don't forget to change the websocket address in the game's code so it can connect to your server!

About

A boilerplate for making online multiplayer games with godot engine and node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published