Giter Site home page Giter Site logo

alexandargyurov / ct.nakama Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 1.0 1.32 MB

A wrapper for heroiclabs/nakama JS client for use in ct.js

License: Apache License 2.0

JavaScript 100.00%
ct-js catmod nakama nakama-js multiplayer heroiclabs realtime plugin

ct.nakama's Introduction

Multiplayer in ct.js!

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!

Video Tutorial Series!

image (image will take you to YouTube once clicked)

Notice:

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.

Getting Started:

  1. You'll need a local instance of a Nakama server before you begin.
  2. Download the latest release of this catmod.
  3. Import the module into ct.js in the Catmods section.
  4. You should be all set! ๐Ÿš€

Example Usage:

โš ๏ธ Not all properties and functions have been documented!

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.

Create a match

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);

Join a match

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);
});

Useful Links

https://github.com/heroiclabs/nakama-js

https://heroiclabs.com/docs/

Getting Help

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 :)

Contributing

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:

  1. Clone the repo
  2. npm install
  3. npm build
  4. A dist folder gets created with a zip for ct.js (you might need to create the dist folder in advance)

Licensing

As the heroiclabs/nakama-js is under the Apache License 2.0, this library also falls under the Apache-2 License.

ct.nakama's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

marcobrunodev

ct.nakama's Issues

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.