Publish to Web - boxgaming/gx GitHub Wiki

GX has the ability to convert your GX-based QB64 game into a web version that can be run in a browser and published online to locations like itch.io.

Examples

Running the Converter

  • Open a command line window and cd to the gx/tools directory.
  • Build the tools with the build.bat or build.sh depending on what OS you are on.
    • This step will only need to be run once after you have downloaded GX
  • Run the gx2web converter (ex: ./gx2web ../samples/overworld/overworld.bas). The resulting web assets will be placed into an output folder in the dist directory.

Sample Conversion Output

C:\Basic\projects\gx\tools>gx2web ..\samples\overworld\overworld.bas
Converting game [overworld] from source [overworld.bas] in directory [..\samples\overworld]...
Preparing output directory [C:\Basic\projects\gx\tools\dist\overworld]
Converting QB64 to Javascript...
        1 file(s) copied.
Copying images...
..\samples\overworld\img\character.png
..\samples\overworld\img\coin.png
..\samples\overworld\img\fire.png
..\samples\overworld\img\flag.png
..\samples\overworld\img\objects.png
..\samples\overworld\img\overworld.png
        6 file(s) copied.
Copying sounds...
Converting maps...
 -> overworld.gxm
Copying web framework...
C:\Basic\projects\gx\tools\web\dev.html
C:\Basic\projects\gx\tools\web\fullscreen.png
C:\Basic\projects\gx\tools\web\gx-logo.png
C:\Basic\projects\gx\tools\web\gx.js
C:\Basic\projects\gx\tools\web\index.html
C:\Basic\projects\gx\tools\web\play.png
C:\Basic\projects\gx\tools\web\qb64.js
C:\Basic\projects\gx\tools\web\test.html
C:\Basic\projects\gx\tools\web\qb64\font.png
9 File(s) copied
C:\Basic\projects\gx\tools\dist\overworld\gx
tmp\__gx_font_default.png
tmp\__gx_font_default_black.png
        2 file(s) copied.

Testing the Web Version

You can test out the results by running the included lightweight webserver (tools/webserver.exe) and opening a new browser window to the output location (ex: http://localhost:8080/dist/overworld/index.html).

QB64 Language Support

The GX-to-Web converter supports a large subset of the QB64/QBasic syntax. In addition to the GX API, the converter also supports the following standard QB64 keywords: Supported Keywords.

Current limitations include:

  • Variables must be declared with a DIM/REDIM statement
    • DIM AS TYPE varname syntax has the best support currently.
    • STATIC variables are not currently supported.
  • All mathematical operators are supported with the exception of the integer division operator ( \ )
  • All conditional operations are supported with the exception of XOR
  • All data types including custom TYPEs are supported with the exception of the following:
    • Fixed length strings are not supported (String*n)
    • _BIT type with specific length (_BIT*n)
    • _MEM data type is not supported
  • Precompiler directives (e.g. $Include, $Checking) are currently ignored