https://github.com/pixelscommander/telekinesis-js
JavaScript multiplayer game engine. Using Node.JS for server and any graphic library for client-side.
https://github.com/pixelscommander/telekinesis-js
Last synced: about 1 year ago
JSON representation
JavaScript multiplayer game engine. Using Node.JS for server and any graphic library for client-side.
- Host: GitHub
- URL: https://github.com/pixelscommander/telekinesis-js
- Owner: PixelsCommander
- Created: 2013-06-23T16:47:28.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-06-24T00:09:14.000Z (almost 13 years ago)
- Last Synced: 2025-04-15T20:09:23.871Z (about 1 year ago)
- Language: JavaScript
- Size: 5.73 MB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

JavaScript multiplayer game engine.
Uses Node.JS for server and any graphic library for client-side.
Why Telekinesis?
----------------
It`s easy way to build structured and well synchronized 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
--------------------------------------
- All game classes that contains game logic have to be universal for server and client;-
- When player invokes action by pressing a button or moving mouse - action sends to server and then to other players;-
- Actions applicable to objects are described in game objects as array of functions called {actions};-
- Names of properties that have to be synchronized during adding objet to scene have to be enumerated as array of strings called {enumerable};-
- Names of propeties that needs synchronization have to be enumerated as strings in array called {sync}.-
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 update 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.