You would use emscripten to translate your C++ game engine into JavaScript. You would also compile the Lua VM together with your engine. Then, the Lua scripts would be data files you would bundle along with the other data files you need.
You are *not* distributing source code when you do this (except for the Lua scripts, of course, exactly the same as in your native distribution). The C++ is not superficially translated from C++ to JavaScript, instead it is compiled, optimized and minified, with results very much like when compiling to an .exe file. Look at the compiled code, it's about as readable as x86 assembly - no clear variable or function names, no obvious high-level structure, just lots of operations (add, load, store, etc.). Emscripten emits such output because it is smaller, so it loads faster, and also it runs faster. But, it has the side effect of being about as readable as native assembly - for similar reasons, as emscripten emits asm.js, which is very low-level, much like a CPU. - Alon On Wed, Feb 11, 2015 at 7:48 PM, Mike <[email protected]> wrote: > TL;DR > How does Unity3D deploy a game to the web? > > ------------------------------------------------------------------------------- > Hello, > > I am building a 2D OpenGL game engine on top of SDL, and I would like to > be able to export games to the web. Tools like Unity3D or GoDot for example > can export a java script application and I want to replicate this process. > In order to do this, have they built some sort of minimal runtime that has > been translated to JS using emscripten? > > Let me clarify the question I am asking. > > My normal tool chain for my game engine is this: > > 1. Write some scripts in Lua that are run > 2. Read them into my C++ Game Engine (basically an interpreter) that > runs the game logic > 3. Compile my engine to an .exe and distribute the scripts alongside > the .exe > > I am struggling conceptually with trying to figure out how I can use > emscripten so that I can target the web as a platform rather than > distributing an .exe with scripts. Do I just translate my entire engine to > javascript and distribute it with my scripts? What if I do not want to > distribute the entire source code(both for safety, and for a smaller > deliverable) > > Thanks for any help, > Mike > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
