Home

Awesome

Image

JavaScript multiplayer game engine. Uses Node.JS for server and any graphic library for client-side.

Why Telekinesis?

It`s easy way to build <b>structured</b> and well <b>synchronized</b> client-server games. BTW racing example uses only 20 lines of networking code.

Getting started

Client scene initialization

//Creating new Telekinesis client
var tsClient = new tsjs.Client('localhost', 3000);

//Setting handlers on object added or removed, this can serve graphic - engine specific logic
tsClient.scene.onAddEntities = MyGraphicEngineAddObject;
tsClient.scene.onRemoveEntities = MyGraphicEngineRemoveObject;

Player action invokation

This is code to execute on key pressed:

this.networkClient.emitAction(this.networkClient.playerId, 'moveKeyDown');

This will notify server and other players about action.

Game server

4 lines of code needed on server side:

var tsjs = require('../../../dist/tsserver');
var server = tsjs.Server.createServer('3000');
server.gameClasses['Car'] = require('../universal/car').Car;
server.playerClass = 'Car';

Building game objects classes

Example class represents game player:

var Car = function(){
  this.x = 0;
  this.y = 0;
  this.speed = 0;
}

Car.prototype[actions] = [
  moveKeyDown: function(){
  this.speed = 10;
},
  moveKeyUp: function(){
    this.speed = 0;
  }
];

Car.prototype.enumerable = ['x', 'y', 'speed'];
Car.prototype.sync = ['x', 'y'];

Scene updating

Scene updates with executing <b>update</b> method of every it`s object. For our example it can be:

Car.prototype.update = function(){
    this.x += this.speed;
}

You can continue with launching and exploring racing example.