Turning your HTML5 games into desktop application can be interesting if you are looking for new ways to distribute your game.
In the first step of this series, we saw how to turn a HTML5 game into a Windows executable file using Electron.
Now we are going to protect our project and change the icon.
Before we start, you have to know there isn’t a 100% secure way to protect your code, so always use an obfuscated version of your scripts before publishing your games in any form.
Now, what to do with the folder containing the game after completing step 1?
First, we use Asar to compact our files. Asar is a simple extensive archive format, it works like tar that concatenates all files together without compression, while having random access support.
To install Asar, open your Command Prompt, PowerShell or any other CLI of your choice and write:
npm install -g asar
You will get Asar installed.
Then, move in your game folder – which I called “4096” and moved to the desktop – and go into
asar pack app app.asar
This way you will pack the whole content of
app folder in a file called
This is how your
resources folder should look now:
Now you can delete
app folder, which is the folder with all your original game files, and
default_app.asar which is the default app, leaving only
app.asar which is your game packed with Asar.
Now it’s time to change Electron default icon, which you can see in the root folder of your game:
Windows is not that user friendly when it’s time to work with file icons, so we’ll use a free third party software called Resource Hacker.
Install and launch it, then open a file:
Open the file with the Electron icon, in my case
4096.exe, and on the left panel you will see a list of resources you can edit.
Select “Icon” and then “Replace Icon …” to replace the icons:
Now just open the icon file you want. Resource Hacker won’t accept png images, so if you want to convert png files to icon, you can use the free online ConvertICO converter.
Now it’s time to save the file…
… and that’s it! Look at the icon of
4096.exe. A backup file has been created at
4096_original.exe, but you can delete it.
Now you can distribute your game with some kind of protection and with a custom icon. Next time we’ll see how to build an installer file, meanwhile download the entire project.