Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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 1293 times)
0 Members and 1 Guest are viewing this topic.
Offline mproncace

Junior Member


Medals: 1
Projects: 1



« Posted 2013-06-05 21: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 22:16:07 »

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

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


me:

--image removed because it's useless--
NO.

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

Junior Member


Medals: 1
Projects: 1



« Reply #2 - Posted 2013-06-05 22: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (27 views)
2014-04-15 18:08:23

BurntPizza (23 views)
2014-04-15 03:46:01

UprightPath (38 views)
2014-04-14 17:39:50

UprightPath (20 views)
2014-04-14 17:35:47

Porlus (36 views)
2014-04-14 15:48:38

tom_mai78101 (61 views)
2014-04-10 04:04:31

BurntPizza (119 views)
2014-04-08 23:06:04

tom_mai78101 (219 views)
2014-04-05 13:34:39

trollwarrior1 (186 views)
2014-04-04 12:06:45

CJLetsGame (193 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!