This is a catmod to enable the use of the Nakama JS Client library into the ct.js game engine. You can now build a fully scalable multiplayer game all with the amazing tools ct.js provides!
Nakama makes it possible to create virtually any type of multiplayer experience you desire. Here are some of its features:
- Low latency realtime engine
- Server-authoritative multiplayer
- Match listing and lobby rooms
- Leaderboards
- Social sign-in: Facebook, Google, and more
- Realtime, room-based, persisted chat channels
- And a lot more!
(image will take you to YouTube once clicked)
This catmod is still in the very early stages of development. It is not production ready! I plan to create documentation, examples and a tutorial series to go through how to use this library all in the near future once the codebase gets stable.
Any feedback is welcome and I am super excited to what we can build with this.
- You'll need a local instance of a Nakama server before you begin.
- Download the latest release of this catmod.
- Import the module into ct.js in the
Catmods
section. - You should be all set! 🚀
You can access the global variable called Nakama
anywhere in ct.js. This is the class which provides you with all the functionality of Nakama.
Property | Description |
---|---|
Nakama.client |
Returns the client |
Nakama.session |
Returns the current client session |
Nakama.socket |
Returns the current socket connection to the server |
Nakama.state |
Returns the current state, defaults to an empty object. Useful for storing current players and other global objects. |
From https://heroiclabs.com/docs/gameplay-multiplayer-realtime/#create-a-match
let response = await Nakama.socket.createMatch();
console.log("Created match with ID:", response.match.match_id);
From https://heroiclabs.com/docs/gameplay-multiplayer-realtime/#join-a-match
let id = "<matchid>";
let match = await Nakama.socket.joinMatch(id);
Nakama.state.players = match.presences
Nakama.state.players.forEach((opponent) => {
console.log("User id %o, username %o.", opponent.user_id, opponent.username);
});
https://github.com/heroiclabs/nakama-js
Please open any issue such as bugs 🐛 or feature requests ✨ on GitHub. You can find me on the ct.js Discord as well if you want to chat :)
All contribution is welcome. Like I mentioned, this is still in the early days of a development, there's no roadmap, no planned features, just me working on it as I go along.
If you'd like to build this yourself:
- Clone the repo
npm install
npm build
- A
dist
folder gets created with a zip for ct.js (you might need to create the dist folder in advance)
As the heroiclabs/nakama-js is under the Apache License 2.0, this library also falls under the Apache-2 License.