Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LWJGL Standalone Launcher  (Read 3144 times)
0 Members and 1 Guest are viewing this topic.
Offline mproncace

Senior Newbie

Medals: 1

« Posted 2013-06-05 19:16:19 »

I recently (3 months ago  Roll Eyes) created a standalone launcher for one of my LWJGL games, and I wanted to share it with the newer members of the community so that they wouldn't need to create their own. This launcher automatically downloads LWJGL and (usually) Slick from the official site (as of writing this, the URL points to my own webserver, as Slick's is down), along with of course the main JAR of the game. It then places them in a specified folder in the application data directory (this works on Windows, Linux, and OS X) under the subdirectory "bin". When it comes time to launch the game, it automatically passes on command line arguments and launches the game.

The launcher also contains an auto-updater, which retrieves a version file from an online host and compares it to a local copy. This version file contains two keys followed by ": " and the value, named "stage" and "version". The stage should contain a String such as "Alpha", "Beta", or "Release", while the version should contain a String representing the complete version number (e.g. 2.9.0). If both the version and stage of the two version files do not match, the launcher will ask the user if they would like to update, after which it will retrieve the new JAR and version file.

Another feature, though minor, of the launcher is that it displays the progress of each download in the form of downloaded/total kb, percentage completed, and a visual status bar.

Currently, configurable global variables include all URLs, the subdirectory containing the "jar" folder in the LWJGL ZIP the game's name (used in the GUI), the folder to be created in the application data directory, and the main JAR's name.

The source code for the launcher may be found here (note that configurables are not set to generic values, and are instead set up for one of my own games), and if you wish to see an example of the compiled launcher, you may click here.
Offline Sammidysam
« Reply #1 - Posted 2013-06-05 20:16:07 »

Upon my first time looking upon your library, I notice the line in Downloader:

os.getChannel().transferFrom(rbc, 0, 1 << 24);


--image removed because it's useless--

You can't just download 16 MB!  What if the download is more than 16 MB?  You have to get the size of the file, then use the figured out size to download that exact amount!  See my similar library to understand what I mean.  Also, I made a thread for my similar library in which tons of suggestions for improving the code were suggested.  For example, you should close things in the finally block.  My thread would probably be a good read, because even though I didn't analyze over the whole source I feel that most of my mistakes are similar to your's.

On a slightly related note, I like comparing dates of updates rather than version numbers.  Then you can have a stage of development called "indev" or something and update without a version number change, which is more convenient.

On a happier note, the getting of LWJGL and having support for all three OSes is very good.  I didn't make support for Mac in my launchers because I don't own one to test it on.
Offline mproncace

Senior Newbie

Medals: 1

« Reply #2 - Posted 2013-06-05 20:25:29 »

Alright, thanks for the feedback. I'll fix the mistake you pointed out, and perhaps add a global that sets whether the launcher compares version files or dates. I'll also be sure to check out your thread as soon as I get the chance.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Ecumene (56 views)
2017-09-30 02:57:34

theagentd (79 views)
2017-09-26 18:23:31

cybrmynd (187 views)
2017-08-02 12:28:51

cybrmynd (185 views)
2017-08-02 12:19:43

cybrmynd (192 views)
2017-08-02 12:18:09

Sralse (203 views)
2017-07-25 17:13:48

Archive (759 views)
2017-04-27 17:45:51

buddyBro (892 views)
2017-04-05 03:38:00

CopyableCougar4 (1441 views)
2017-03-24 15:39:42

theagentd (1326 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!