Page 1 of 1

Running HTML5 engines on Node.js

Posted: Thu Aug 25, 2016 2:14 am
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?

Re: Running HTML5 engines on Node.js

Posted: Thu Aug 25, 2016 3:45 am
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?

Re: Running HTML5 engines on Node.js

Posted: Thu Aug 25, 2016 2:49 pm
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.

Re: Running HTML5 engines on Node.js

Posted: Fri Aug 26, 2016 1:31 am
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.

Re: Running HTML5 engines on Node.js

Posted: Fri Aug 26, 2016 2:39 am
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.

Re: Running HTML5 engines on Node.js

Posted: Fri Aug 26, 2016 3:43 am
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.

Re: Running HTML5 engines on Node.js

Posted: Fri Aug 26, 2016 2:14 pm
by hallsofvallhalla
Will be a fun experience too.

Re: Running HTML5 engines on Node.js

Posted: Fri Aug 26, 2016 11:56 pm
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.

Re: Running HTML5 engines on Node.js

Posted: Sat Sep 03, 2016 3:29 am
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.

Re: Running HTML5 engines on Node.js

Posted: Sat Sep 03, 2016 3:47 pm
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.