How to run Wade on a node.js server (headless)

Thread title says it all, is it possible and how?

1 Comment

Hi Arkam and welcome to the forum

Sure it's possible, but obviously you won't get any of the client-side aspects of Wade - no rendering, sprite management, etc.

However it's potentially useful to run Wade on a node server, in case you have a multiplayer game and want to reuse the same codebase that you've used for your single-player game as part of the server logic. You may want to use Wade for pathfinding, serialization of Scene Objects, and other things that do not require a screen / window to display stuff.

Wade itself relies on a couple (literally just 2) things that exist in the DOM but won't exist in a node.js process. As long as you do not use those things explicitly, you can just redefine them at the top of your node app / module before including wade:

Image = function() {};
window = {};

That's all you have to do. Do not call wade.init(), as that will try to create the default set of procedural sprites (among other things), initialize audio, etc. and all those things will fail on a node server. But feel free to call wade.findPath, wade.worldPositionToScreen, and generally any wade functions that do not directly do any Sprite drawing.

Let me know if you encounter any problems with this, always happy to help.

Post a reply
Add Attachment
Submit Reply
Login to Reply