
libGDX for Coding Applets
http://fivedots.coe.psu.ac.th/~ad/libgdx/

Andrew Davison, Jan. 2023
ad@fivedots.coe.psu.ac.th


Download gdx-setup.jar from 
https://libgdx.com/wiki/start/project-generation

When you run it, create code for the 'Desktop' *and* 'HTML' platforms.
In what follows, I've assumed the Project Name was changed to 'test', 
but the package name and game class strings were left unchanged 
as 'com.mygdx.game' and 'MyGdxGame'.

There are 3 folders in this zip file:

  code/   
  assets/  
  launchers/

-----------------------------
In code/:

 * DrawCell.java
 * LineShape.java
 * MyGdxGame.java
 * OvalShape.java
 * RectangleShape.java
 * Shape.java

Copy all of these to test\core\src\com\mygdx\game,
overwriting the MyGdxGame.java file that's there
already.

-----------------------------
In assets/:

 * data/
 * glassy/
 * metal/
 * query.png

Copy all of these to test\assets
The badlogic.jpg file that's there already can
be left untouched.

-----------------------------
In launchers/:

 * DesktopLauncher.java
 * HtmlLauncher.java

Use these files to overwrite existing files at: 
  test\desktop\src\com\mygdx\game\DesktopLauncher.java
and
  test\html\src\com\mygdx\game\client\HtmlLauncher.java


------------------------------------
Compilation, Execution, Installation

Open a command line prompt in test/, where
you'll find a Windows batch script (gradlew.bat)
and a Bash script (gradlew). Use one of them to
execute three commands:

gradlew desktop:run

gradlew html:superdev

gradlew html:dist


Stage 1
-------
Use "gradlew desktop:run" to generate and run the desktop version
of the application. The very first call is a little slow since 
libGDX fires up a daemon process, but subsequent compilations
are quick; you should use this command during program development.

Note that gradlew issues a *lot* of warning messages, but these can
be safely ignored. Actually errors are reported in 'deadly' 
red-colored text.

Stage 2
-------
Use "gradlew html:superdev" to generate the HTML version which is
run via a local jetty-based HTML server. Access the application's
webpage by typing:

http://localhost:8080

into your browser. On one of my test machines, html:superdev takes 
about 35 seconds to complete.

Stage 3
-------
Use "gradlew html:dist" to generate the distribution code for uploading
to a real web server. On the test machine, this command takes about
52 seconds, not including the time to move the files over to 
the server.

gradlew issues a *lot* of warning messages about deprecated
fetaures, but these can be ignored. 

The generated code is stored in the folder test\html\build\dist\

Copy everything over to your website:  
 * assets/
 * html/
 * WEB-INF/
 * index.html
 * styles.css

In my case, I renamed index.html to app.html, and embedded a call to
it in an iframe in: 
http://fivedots.coe.psu.ac.th/~ad/party3/libgdx/index.html

The iframe code is:

<p align="center">
<iframe src="http://fivedots.coe.psu.ac.th/~ad/party3/libgdx/app.html" 
        width="800px" height="600px">
</iframe>
<p>

