Running HTML5 engines on Node.js

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Running HTML5 engines on Node.js

Post by Jackolantern »

Has anyone here ever gotten a major HTML5 engine (or really any engine, or their own engine) to run in headless mode on Node.js? If you aren't familiar with why someone would want to do this, it would be the beginning of an online game. Because many online games (and pretty much all MMORPGs) need "authoritative servers", the server has to be running the official instance of the game to update all of the clients to state of the world. If your game uses physics, it is pretty much a must to get your engine working on the server.

Maybe Halls, have you done this before? I have been looking around, and it seems the major choices (PhaserJS, ImpactJS, Kiwi, etc.) are all written pretty well assuming the DOM and other browser resources will be available all over their code. Some people have got it working (here is a post from 2014 where someone got Phaser running in node, but it looks quite hacky) but it is usually a ton of work.

I suppose it may be possible if you don't use physics, but rather stiff world movement, to do the calculations yourself but that could get difficult as well to get it to work just right. So, anyone have any experience with this?
The indelible lord of tl;dr
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Running HTML5 engines on Node.js

Post by Jackolantern »

Okay, after reading this I think getting the whole game engine running on the server is probably not the way to go. Rather porting or recreating the logic from Phaser and your game are the way to go.

So I guess to rephrase this, has anyone ever had any luck with client-prediction, interpolation and generally keeping real-time state with a server before using an HTML5 engine on the client-side?
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Running HTML5 engines on Node.js

Post by hallsofvallhalla »

Yep you are heading in the right direction. I have tried multiple times to get a few engines(Melon, Phaser, ect) to run on the server side. It quickly becomes a jumbled mess of strung out code full of issues.

I basically created a state engine so to speak on the server that mimics what the client is looking for. Player has a copy of their class on the server. Player fires, client checks to see if they can --> server sees it and does any checks on the player class to make sure they can, like the client. --> server send back to all clients that player fired. Pretty common way to do it, The only thing I have not had much success with is interpolation and prediction.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Running HTML5 engines on Node.js

Post by Jackolantern »

Hmm....that is basically what I would need to do to be able to pull off my optimal idea: lots of client-side prediction and interpolation. I would also need some form of the Phaser physics engine running on the server (likely Arcade Physics). This is probably going to get ugly :P

I have also thought several times about really picking-up Isogenic Engine. It has basically already built everything I would need for the infrastructure. But it just makes my head hurt. It is a giant, well-engineered machine but I just feel like it would take me forever to really wrap my head around it and feel comfortable with it. I may go back and give it another look, though.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Running HTML5 engines on Node.js

Post by hallsofvallhalla »

Its tough....but it is free now. It is no doubt a great option but has a big (only by choice) learning curve. If Rob would just make a tutorial explaining the multiplayer side well it would be the weapon of choice in any battle.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Running HTML5 engines on Node.js

Post by Jackolantern »

I also think that Isogenic may be overkill for what I want to do. I am wanting more simple wall collision-type physics, for example. Isogenic is an incredible piece of engineering, but I think Rob made it to work not only for online RPGs, but even online action games which are tough to do with WebSockets.

I am actually leaning towards what will probably be a dumb decision: rolling my own game engine. That way I could make it from the ground-up with the intention of it being easily runnable on the server through node. Perhaps make it entirely modular.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Running HTML5 engines on Node.js

Post by hallsofvallhalla »

Will be a fun experience too.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Running HTML5 engines on Node.js

Post by Jackolantern »

Okay, screw making my own engine lol. I think I have a better idea. Basically, create my own little physics engine inside of Phaser. Use Phaser for a lot of what it is good at (Pixi.js, animations, tilemap support, entities, etc.) but layer my own physics engine onto it to actually control the action so that I can simply move the loosely-coupled physics engine to the server. I think that would be the best option.
The indelible lord of tl;dr
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Running HTML5 engines on Node.js

Post by Jackolantern »

I went back and looked at Isogenic Engine again. I honestly think the only thing holding it back from being a phenomenon is a lack of resources to get started. Really all I can find is a video series that gets a simple skeleton set up and the API reference. For an engine with such a large learning curve and with so much power, it could potentially take a dev months if not a year to really feel comfortable with it.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Running HTML5 engines on Node.js

Post by hallsofvallhalla »

agreed. Once you learn it will last you many many years. I had a simple game made with it and even did some tutorials but man it was so easy to get lost using it.
Post Reply

Return to “General Development”