Sign in to follow this  
jalex

Do you obfuscate your game code and what are the benefits of that?

Recommended Posts

I have already minified my Javascript code for a 2D game I make, mainly to make it smaller and fit in just one file. I'm now thinking of obfuscating it as well, but started wondering what the purpose of that would be for a game? The game itself does not contain any secret algorithms that need protection, and if someone wants to steal my game and put it on his or hers website then I guess obfuscating the code won't help (unless parts of it are on a server), since it is just to copy the code and uploading all the images and sounds. Also isn't there a risk the game becomes slower if obfuscating it?

How do you do it? Do you obfuscate your code, or do you just let the code be there as it is?

Share this post


Link to post
Share on other sites

Well one thing to consider would be if your game is sitelocked, then obfuscating the code is going to make it much more difficult to remove the site lock.

Obfuscating generally does make the game slower. Not only you end up with more instructions, but you often end up with a program that's harder to optimize at JIT compile time. But if you only obfuscate the high-level logic only and not the low-level (framework) code, than you should be alright in most cases.

Personally I use either my own framework or Wade for my games. The latter comes with a script to auto-obfuscate your games (or at least it did, I'm not sure about newer versions). The framework that you are using may have some feature like that built in.

Share this post


Link to post
Share on other sites
On 11/5/2018 at 12:53 PM, vamos said:

Well one thing to consider would be if your game is sitelocked, then obfuscating the code is going to make it much more difficult to remove the site lock.

Obfuscating generally does make the game slower. Not only you end up with more instructions, but you often end up with a program that's harder to optimize at JIT compile time. But if you only obfuscate the high-level logic only and not the low-level (framework) code, than you should be alright in most cases.

Personally I use either my own framework or Wade for my games. The latter comes with a script to auto-obfuscate your games (or at least it did, I'm not sure about newer versions). The framework that you are using may have some feature like that built in.

Thanks for the answer!

No my game is not sitelocked. I use my own framework, and I managed to obfuscate my code online (some of the sites generated an error), but it is an extra step to do every time I'm updating my game, so I'm considering skipping it.

Share this post


Link to post
Share on other sites

I have a WebGL game that handles encrypted 3D models, and I apply obfuscation on the code part that does the decryption. Yeah I know JavaScript obfuscation is not 100% safe, but at least it is enough to protect such models from being stolen by some script kiddies. Since just a small part of the code is obfuscated, the performance impact is minimal.

Share this post


Link to post
Share on other sites

I use Uglifier to minimize my code and reduce all of the function and variable names to 1 or 2 letters and strip out comments. Since my core framework is RubyOnRails it bundles it all together with any other Javascript I'm using, which makes it look like a real mess in the browser upon deploy without any loss of performance. You can also get downright diabolical and base a few of your values on database tables, which means it won't run correctly unless the code can query YOUR database; that makes it crash if someone just tries to copy/paste your whole site. (It can also help to use ES6 syntax, because that REALLY throws off the the beginners)

This has worked pretty well for making my own frameworks, but since I'm now switching to Pixi.js things got a bit more complicated, since the function names would need to be intact. So I'm now building Ruby Gems for Pixi, which will bundle the code into the rest of the app on deploy, and I'll be testing how well that works and providing an update to the forum when I've got worthwhile results.

If you'd like to test how well it worked when making my own frameworks from just vanilla JavaScript, feel free to check out my showcased game on this forum. It's called Loyal Online and has been Uglified and bundled into the app. For comparison, I've already provided a link to the source-code on my Github(I've moved on from it, so I published it Open-Source to the community), so you can evaluate for yourself how well this method works.

While nothing will stop someone skilled and determined enough to steal your code in a Web-based app, you can make it so much trouble that anyone with enough skill to pull it off would be better suited to build their own, leaving the copy/paste gremlins out in the cold.

Hope that helps; I'll provide updates when I finish the Ruby Gems for Pixi. ^_^

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.