Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ImpactJS emulation layer for Node.js, to enable the class system, module system and native type extensions from ImpactJS on the server.
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
lib
README.md
package.json

README.md

Description

Enables various features from the ImpactJS HTML5 game engine in Node.js to enable code sharing and re-use between the client and server side.

The features that are emulated or re-created are:

  • The Module system
  • The Class system
  • The Native type extensions

Use Cases

  • Server authoritative multiplayer games
  • High score validation - record inputs from the game, send over to server after level is done, server can then replay using the same logic and code on server
  • Use or embed game data or game structures from your game into your webapp

Usage

Note: Enabling the systems should only be done in one place, in the entry point of your app. After that, their effect is global.

Enable the Class System:

require("node-impact-emu").useClass();

Enable the Module System:

// Note: Must pass in the root class path folder. This can be the same lib folder that
// contains your client-side modules
require("node-impact-emu").useModule(__dirname + '/lib');

Enabling the module system allows you to manage all modules using the ImpactJS style ig.module('...').requires('...', '...', '...').defines(...); rather than using node.js's require function.

Enable the Native JavaScript Object Extensions:

require("node-impact-emu").useNative();

You can also enable more than one system at a time by chaining:

require("node-impact-emu").useNative().useClass();

Or you can enable everything:

require("node-impact-emu").useAll(__dirname + '/lib'); // Also takes class path folder for useModule

See example folder for an example app.

Disclaimer

Enabling these features diverges from typical Node.js development practices. The global namespace is modified, and modules are no longer entirely self-contained. Use at your own risk.

Something went wrong with that request. Please try again.