#10 Steps to Exe for PC or Mac

6 messages · Page 1 of 1 (latest)

torpid sundial
#

Convert GBStudio Web Export to Executable for Windows or Mac in 10 steps.

#

So let me prefix this with - I am not a web dev and the following may be incorrect or not quite accurate.

I'm just sharing this to try help folk who'd like to try this! ... but ....

I've used these steps today to build Windows and Mac versions of Cave Dave.

Here's 10 steps to convert your GBStudio web export into an .exe for Windows or a .app for Mac.

#

Prerequisite:
npm installed. (Web will help here - beyond the scope of this message)

#
  1. Use GBStudio to export your game for web

  2. Copy contents of ‘web’ folder to new <game name> folder

  3. Terminal to <game name> folder (open a terminal inside this folder)

  4. Install Electron in this folder.
    For Mac:
    sudo npm install --save-dev electron@latest
    For Windows:
    npm install --save-dev electron@latest

  5. Install Electron Packager in this folder.
    For Mac:
    sudo npm install --save-dev @electron/packager
    For Windows:
    npm install --save-dev @electron/packager

  6. Place the two files attached to this message into the folder ('package.json' and 'main.js')

  7. Open your 'index.html' file in an editor

We're making a small change to this file so the audio will work without having to click on the Window.

Right before '</head>' add these lines:

<script type="text/javascript">
          function focusPlayer() {
            setTimeout(focusPlayerNow, 1000);
          }
          function focusPlayerNow() {
            document.getElementById("game").click();
          }
</script>

These are 2 functions we will call when the game loads to simulate a click which enables the sound

  1. Change the '<body>' line to this:

    <body onLoad="focusPlayer();">

That's what will trigger our functions in 7 and enable the sound after 1 second.

  1. Back to the Terminal. Time to build the game!
    For Mac: (Silicon Mac - I don't have an Intel sorry but it shouldn't be too tricky)
    electron-packager . <game name> --platform=darwin --arch=arm64 --asar
    For Windows:
    npm exec electron-packager . <game name> --asar

  2. All going well you'll have a new folder now. Look inside that and BINGO! There's your .app (Mac) or .exe (Windows)

#

Again, I am NOT a web dev, I hack stuff and swear until things work !:)

So if there's something we can change to make this better/easier let everyone know. Web dev seems to have a heck of a lot of 'well actually...' !:) So be nice.

torpid sundial
#

Executable for PC or Mac