Skip to content
Greg edited this page Aug 23, 2013 · 7 revisions

What does it do?

Cloak is a library for writing networked HTML5 games using Node.js. By "networked" I mean they are either server-validated single-player games, or they are multiplayer games. Cloak provides a variety of systems that are useful for networked games, such as:

  • Automatic user identification and reconnection
  • Lobby system
  • Room system
  • Chat

How does it work?

Your game will have a client and a server. The client is a HTML5 and JavaScript web application. It can have its own backend, or it can be served as static files by a standard web server such as Apache or Nginx. The client will use the Cloak client library. The server is a Node.js application. The server will use the Cloak server library.

Diagram

If you are familiar with Socket.io this may look familiar. You can think of Cloak as a game-specific version of Socket.io with extra sugar. It currently uses Socket.io as a dependency, but in the future we plan on allowing Cloak to use other network libraries or stand alone.

Creating the server

To start making a game using Cloak, make sure you have the following software already installed:

First, create a directory for your server and add package.json and server.js files. A good starting package.json looks like this:

{
  name: 'My Cool Game'
}

Before writing your server code, install the Cloak NPM module. Actually, you can't do this yet! But once you can, you will type npm install cloak --save. The --save flag will add it to your package.json as a dependency. Later on you can use npm install to install all dependencies listed in the package.json.

Now you can create your server.js. Use this as a starting point:

var cloak = require('cloak');

cloak.configure({
  port: 8090
});

cloak.run();

[TODO]

Clone this wiki locally