Posts Tagged ‘infrastructure’

LWJGL on Maven central

Saturday, October 22nd, 2011

Hi we are happy to announce that LWJGL is available in Maven central. We worked hard with the @LWJGL people to make this possible.

Why was it important to get LWJGL into central?

Well, one of the biggest pains when using maven is having your dependencies available from central, if they are, you just need to add a little snippet of XML and you are done, if they aren't, then you need to install them manually to your local repo or to a private maven repo.
This is a problem in itself but this also means that projects that depend on something that isn't available in central, can't get into central themselves, making the work needed to use it grow exponentially.

Previous work

In order to get LWJGL into central we had to work first with @Endolf to get JInput into central so a huge thanks to him as well.

Future plans

Now that we got LWJGL into maven central, we can start thinking about trying to convince the authors of other useful libs that use LWJGL like Slick2D, libGDX, nifty-gui, etc to make their libs also available on central (of course we would love to help make this a reality as well).

If you use LWJGL with maven, we would love to hear from you and feel free to ask us anything.

More information:

VN:F [1.9.22_1171]
Rating: 5.0/5 (3 votes cast)

Second attempt at Highscores for games

Tuesday, June 14th, 2011

Some time ago we started a web application on github named datastore-server which allows us to store data for our games in a remote server hosted on Google App Engine. Since the first data we needed to store was game scores, and we required more specific queries for them, datastore-server end up being a high scores server, at least for now.

We made an introduction of some of the requirements we wanted for the scores server in a previous post, we made some modifications to the basic concepts.

Profile

First of all, we added a new structure which identifies the player and has the following fields:

Profile {
    privateKey : String - a unique private key owned by the player on the client application, used to submit scores
    publicKey : String - a unique public key used to identify scores
    name : String - the player name
    guest : Boolean - if the profile is guest or not
    }

Score

Score structure has been modified to have a profile reference, and also some extra data required for scores filtering improvement (filter by date range):

Score {
    .... (previous data)
    profilePublicKey : String - a reference to the profile owner of the score 
    year : Integer - the year the score was submitted (calculated in the server)
    month : Integer - the month of the year the score was submitted (calculated in the server)
    week : Integer - the week of the year the score was submitted (calculated in the server)
    day : Integer - the day of the year the score was submitted (calculated in the server)
    }

The server now provides the following features:

  • create guest and non-guest profiles for score submission
  • submit a score for a game given a profile
  • request scores given a criteria

Creating and updating profiles

To create profiles datastore-server provides a query named /newProfile with two parameters:

  • name : String - represents the name of the profile
  • guest : Boolean - if the profile is guest or not

The query returns the profile structure as JSON so that the client can save the private and public keys that are generated on the server.

We also provide a way to change a guest profile name and to make it be non-guest using the /updateProfile query:

  • privateKey : String - identifies the profile
  • name : String - the new name we want for the profile

Submitting a new score

To submit a new score we now need a guest or non-guest profile, it still uses the same query /submit with the same parameters plus the profile privateKey.

Requesting scores

To ask for the scores of a game we have the /scores query with the addition now of two new parameters:

  • distincts : Boolean - if scores should be filtered to return only one score per player (optional, true by default)
  • range : enum { day, week, month, all } - filter best scores by today, this week or this month respectively (optional, all by default)

So, for example, if you want the 50 best scores of the week for a game, you will query /scores?gameKey=something&limit=50&range=week.

Datastore Java client

Finally, to communicate in an easy way with datastore-server we created a Java library named datastore, also on github, which abstracts all communication stuff using apache http-client and also provide classes for score and profile concepts.

If you want to see high scores in action, you could play Face Hunt on PC here or on Android here, also you could take a look at the source code here.

Both projects datastore and datastore-server will probably change in order to incorporate other data storage beside scores.

Hope you like it.

VN:F [1.9.22_1171]
Rating: 4.5/5 (2 votes cast)

Getdown

Tuesday, February 22nd, 2011

Getdown is a deployment library like Java Web Start, which provides also an integrated update process for your game. It was started to replace Java Web Start based on the premise that using Java Web Start has a lot of downsides. Getdown is mainly designed to launch games in the desktop like Java Web Start does, aditionally, it creates an installation folder structure and a launch icon on your desktop if you want.

We've talked about it a bit on our deployment ways blog post, but now we are making a deeper article based on the experience from testing it a bit with one of our games.

Getdown library is used as a game's launcher, which updates your game by downloading all required specified resources before the game starts.

You could use the getdown applet to perform all download and installation process from a web browser or you could create a platform specific installer and, after the game's launcher is installed as a desktop application, derive to it the rest of the process.

It uses a text file named getdown.txt to configure all your application needed resources, natives, custom jvm parameters, etc, and a digest.txt file to check integrity of all downloaded resources before launching the game. If you deploy it as the getdown applet, then you need to sign the digest.txt file with the same certificate used to sign the getdown.jar in order to run the applet with privileges. Here is the getdown.txt of Puzzle Pirates as an example.

Pros

  • It uses a single file to configure the application in a similar fashion Java Web Start does with the JNLP file, with some extra options. This is good because it is independent from the deployment option used, you can use the installer or the browser applet and use the same configuration file.
  • Provides a way to specify platform specific resources to be downloaded only if you run the game on that platform.
  • The loading screen is customizable like the LWJGL Applet Loader. Java Web Start provides a way to customize loading screen but you need at least Java update 18 (haven't tried it yet).
  • It validates all dependencies using the signed digest file. This is very interesting because you only need to sign one file with all the resources digests, without having to sign each file.
  • It provides a way to update your game by downloading a patch and applying it in the client machine. It requires you work with versions to use that feature (docs about versions are not ready yet).
  • Open source project with good documentation.
  • It is being used by professional games.

Cons

  • It only uses RSA for the certificate private key, so if you already own another type of private key it will not work.
  • Doesn't handle pack200-gzip encoding and stuff. It doesn't even have a way to force to download a .pack.gz either, like the LWJGL Applet Loader does.
  • It is very slow for checking files to download info, like the LWJGL Applet Loader it is not using concurrent HTTP requests for that. Java Web Start and New Generation Plug-in Applets does and it starts faster.

Note: we don't know exactly how it is doing all the cache stuff, from the wiki page it seems like it doesn't use Java Web Start cache, but from the practice it seems it is using it. It seems to be a bug, for that reason we didn't want to comment the cache stuff in the pros/cons section.

The Getdown developers have a lot of other useful libraries for Games development, take a look at them at Three Rings code page. Some games using Getdown are Pets Vs. Monsters from Sweet Robot, Puzzle Pirates, Bang! Howdy, Spiral Knights from Three Rings and Tribal Trouble 2 from Oddlabs.

We have one game deployed using getdown to test it, however if you accepted our certificate before, it will ask to accept again as it is using a new one because the second cons we mentioned before. If you want to test it, click here.

Conclusion

The user experience when playing a game deployed using Getdown with a customized loading screen is really professional and it feels like you are playing a non Java Game (hate to say that, but we can't avoid bad Java preconceptions).

References

UPDATE: added a new entry in the pros section about an update game feature by applying a patch

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

LWJGL Applet Loader

Thursday, February 17th, 2011

In a previous post we talked about Java Games deployment options, in this post we want to talk about one custom solution provided by the LWJGL: the LWJGL Applet Loader.

The LWJGL Applet Loader is an Applet which performs a lot of common deployment tasks:

  • It shows a nice and customizable loading screen when deployment is being processed, with detailed messages for each task: downloading file.jar, extracting file.jar.gz, etc.
  • It downloads all required dependencies. If they are compressed using gzip, LZMA or Pack200, it extracts them.
  • It has a cache for all your dependencies so if one dependency is not modified on the server, then it is not downloaded again.
  • It configures the Java library path to load all your native dependencies.
  • Finally, it runs your game's applet.

A feature in mind when developing the LWJGL Applet Loader is that it should start as fast as possible, for that, the jar of the Applet Loader should be really small. The idea is to speed up all the Java loading screen so it can show quickly your custom loading screen.

It provides a lot of parameters in order to let you customize deployment stuff, like which natives dependencies you need for a specific platform, the logo and progress bar, etc. Full documentation of the parameters is on the API docs and you also have a great tutorial at LWJGL Wiki.

This is how it looks when loading an Applet using the LWJGL Applet Loader with the default loading screen:

note: Even without customization, it looks much nicer than Java default loading screen.

Pros

  • It lets you customize loading screen, and create Applet using natives support in an easy way.
  • It starts fast. This avoids some browser freeze bug when starting a Java Applet, like Firefox on Linux platforms.
  • It handles different compression options like gzip and LZMA, it also handles Pack200 jars.
  • It works on Mac OS, that is a big difference versus running New Generation Plug-In Java Applets, because they are disabled on Mac OS.
  • It is open source and the guys maintaining it are always open to receive patches and improvement ideas.

Cons

  • Pack200 and compression stuff is not done automatically, you have to specify exactly which file you want to download (example: you have to specify that you want to download somedependency.jar.pack.gz instead of having the Applet Loader to detect automatically which version to download by receiving the content encoding from the server).
  • Assumes you need native dependencies, so you need to fill some Applet parameters even if you don't need them. (we want to add an RFE for that)
  • It doesn't use the same cache other Java Applets or Java Web Start use. That means you have to download twice one Applet distributed using LWJGL Applet loader and Java Web Start, and it will cost you double space.

To see LWJGL Applet Loader working you can try one of our games here (warning: link could be broken in the future) or you can try a working and stable version of a game using LWJGL Applet Loader here, its name is Minecraft, don't know if you know about it.

In one of the next posts we want to talk in detail about another deployment option we mentioned before, now that we have some experience using it: getdown.

References

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Games as Applets 3

Thursday, February 10th, 2011

Following our Games as Applets series, we want to talk about the Wordrpess Page Template we are using in order to deploy our games as Java Applets inside the Blog.

WordPress Custom Fields

When creating a new blog post or page, the creator can add metadata using WordPress Custom Fields, to be processed later by the PHP templates associated. In our case, we are using the following custom fields:

  • applet_height - height of the applet.
  • applet_width - width of the applet.
  • applet_screenshot - URL to a screenshot of the game
  • jnlp_url - URL to the JNLP for launching the game.

WordPress Page Templates

After adding metadata to our posts or pages, we need to make a WordPress Page Template in order to process it. In our case, we created a PHP template for our games deployed as Java Applets using the structure explained in our last post about Games as Applets. Our games template looks like this file.

Note: I didn't want to put all the PHP file code directly in the post because it is too large.

This is how we get the post metadata:

<?php 
	$jnlp_href = get_post_meta($post->ID, "jnlp_url", true);
	$applet_width = get_post_meta($post->ID, "applet_width", true); 
	$applet_height = get_post_meta($post->ID, "applet_height", true);  
	$applet_screenshot = get_post_meta($post->ID, "applet_screenshot", true);  
?>

And this is how we pass the values to the javascript:

<?php echo '

' ?>

Once the page template is created, if we want to add a new page for a game, we only have to select it from the templates list and voilá.

Conclusion

Using WordPress Page Templates and Custom Fields, we can reduce the information of the game's page to game's related information only, and move all common logic and information between game pages to the page template.

This is how it looks to edit a game page:
Game Page being Edited

Note: there is no applet tag or javascript in the page.

Also, if we modify the page template, we have all game pages updated, that could be really useful if you need to fix a bug or make an improvement to the page but could be a problem in case we introduce a new bug.

One problem not resolved yet is if you want to change the WordPress Theme, you will have to migrate the page template. I don't know exactly if you can create a page template theme independent.

References

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Ways to deploy a Java Game

Wednesday, February 9th, 2011

When you develop Java games for PC, you have different ways to deploy them. We want to talk a bit about some of them.

Downloadable

The user has to download the game to run it on his machine, probably it comes with an installer to install the game before he can play it.

Pros

  • The game can be played offline when it has no online requirements.
  • User knows where the game is installed and sometimes decides where he wants to install it. They also can uninstall the game.
  • It is the only way to deploy a game in portals like Steam, Altitude Game is an example of that.

Cons

  • Users have to download a patch each time there is a new version. As a developer, you can implement something to download patches and apply them.
  • As a developer, you have to implement an installer. Also, you have to make different installers for each platform, an example of that is Revenge of the Titans (ROTT) from Puppy Games.
  • You have to create patches and deploy new files to be downloaded each time you have a new version of the game after a bug fix or new feature. Else, you force people to download large files each time you have an updated version.
  • Java Runtime Environment (JRE) must be installed or you have to embed JRE with your game. In the second case, your game file becomes bigger, for larger games that is not a problem but for small games embedded JRE could be, for example, 300% of the game size (at today, JRE weight is about 20MB). Even though there could be a JRE installed, being able to execute your program directly depends on a good configuration of the JRE within the OS. To solve that, developers usually generate a native wrapper that detects where the installed JRE is, and if it is not installed prompts the user to download one, or reports the error to the user.

Applets

Java Applets works inside the browser, as well as other web technologies like Flash and Unity. Users only have to open a page with a Java Applet inside and it is loaded by the web browser. Minecraft is an example of a successful Java Applet Game (it has other deployment options as well).

Pros

  • Users only have to follow a link to play the game. No game install is required.
  • Users are always playing the latest game version, because it is being downloaded from the server.
  • As other web technologies, you can add information or even ads to your applet page without having to put that inside the game.
  • Java Applets are as powerful as a Java Desktop application.
  • New Generation Java Applets accepts Java Networking Launching Protocol (JNLP) files (more info on next blog posts).
  • Pack200 and GZip compression support to reduce jar download sizes (only using plugin2).

Cons

  • JRE must be installed on the client machine. However, nowadays you can assume the required plugin is installed on most of the client machines.
  • You need a web server to deploy your game jars or you have to use a games portal like GameJolt or Games4j.
  • Dependning on the Java Applet technology you are using (plugin2, etc), firefox can freeze when the applet is loading, or could not work on Mac OS (more information on next blog posts).
  • As a developer, you need to sign your jars with a certificate if you want to have full access (to do extra stuff like writing a configuration file on user's home folder).
  • If you ask for full access, a security dialog box is displayed. It tends to scare users, if you have a valid certificate then it is a bit less scary.

Web Start

Java Web Start is some kind of mixing between the last two. As developer you use a JNLP file to describe which resources must be downloaded. Users only have to click on a JNLP link and then the game is opened automatically by Java Web Start.

Pros

  • Users only have to follow a link to play the game. No game install is required.
  • Automatically downloads the latest version of your game from the server each time the user wants to play a game.
  • It has a cache for downloaded resources, so if you only update one jar then it is the only one downloaded by the user's machine the next time the user opens the game.
  • As a developer you can specify to run the game offline.
  • It has a clean way to specify your game's resources using the JNLP file.
  • Pack200 and GZip compression support to reduce jar download sizes.

Cons

  • Some browsers are not configured correctly (for example, Google Chrome) and they don't open the JNLP automatically using Java Webstart, they just download the file.
  • Same thing with certificates and signing as the Java Applet.
  • As a developer you need a web server to put all your game's resources, we don't know any portal which accepts JNLP games yet.
  • Java Webstart Cache and Log files are difficult to find on user's machine.

Getdown

Getdown is a custom solution made by Three Rings in order to replace Java Web Start technology due to its limitations, as it is explained on Getdown's project Wiki. We lack experience and information about this solution, so the pros/cons section could be a bit empty.

Pros

  • Open source, that means you know what is happening, and you can collaborate, something impossible with Java Web Start.
  • Working examples of mmo games like Sprial Knights from Three Rigns and Tribal Trouble 2 from Oddlabs.

Cons

  • It is custom made. That means, as a developer you have to be aware that if something goes wrong you may have no support (note the conditional). But can't say it is really a cons because with Java Web Start you don't have any support at all from Oracle's team.

References

  1. Altitude Game - http://altitudegame.com/
  2. GameJolt - http://gamejolt.com/
  3. Games4j - http://games4j.com
  4. Getdown - http://code.google.com/p/getdown/
  5. Java Plug-In Technology - http://www.oracle.com/technetwork/java/index-jsp-141438.html
  6. Minecraft - http://www.minecraft.net/
  7. Oddlabs - http://oddlabs.com/
  8. Pack200 - http://download.oracle.com/javase/1.5.0/docs/guide/deployment/deployment-guide/pack200.html
  9. Puppy Games - http://www.puppygames.net/
  10. Revenge of the Titans - http://www.puppygames.net/revenge-of-the-titans/
  11. Sprial Knights - http://spiralknights.com/
  12. Steam - http://store.steampowered.com/
  13. Three Rings - http://www.threerings.net
  14. LWJGL Wiki - http://www.lwjgl.org/wiki/index.php?title=General_FAQ#Distributing_LWJGL_Applications

UPDATE: added link to LWJGL wiki page about how to distribute LWJGL Java Applications (most of them applies for Java Applications in general)

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)

Games as Applets 2

Friday, January 21st, 2011

Talking with kappaOne, one of the LWJGL developers, he pointed us that our applet solution has one problem. When js is disabled or it has failed to load, then the applet tag is not written, then the game is not loaded.

In order to fix this problem, we adopted part of his solution. He always creates the applet tag for the game and then hides it using js. If for some reason js fails, then the applet starts automatically.

The new html needed looks like this:

Html:

  
<div id="applet" class="applet" align="center">
	<applet id="gameApplet" width="800" height="600" code="com.gemserk.games.appletverifier.AppletVerifier" archive="http://www.gemserk.com/appletverifier-0.0.1-SNAPSHOT.jar">
		<param name="jnlp_href" value="http://www.gemserk.com/prototipos/zombierockers-webstart-release/launch-applet.jnlp" >
	</applet>
</div>

And this is the modified js with a merge between his solution and ours:

Javascript:

  
var width="800";
var height="600";
var jnlp_href="http://www.gemserk.com/prototipos/zombierockers-webstart-release/launch-applet.jnlp";
var screenshotUrl="http://blog.gemserk.com/wp-content/uploads/2010/12/zombierockers-screenshot01.jpg";
var appletTag;

var requiredVersion = '1.6.0_10+'
var attributes = { code:'com.gemserk.games.appletverifier.AppletVerifier',  width:width, height:height} ; 
var parameters = {jnlp_href: jnlp_href}; 

hideApplet(); 

function hideApplet(){
	var appletbox=document.getElementById('applet');
		appletTag = appletbox.innerHTML;

	if (navigator.appName == 'Microsoft Internet Explorer') {
		var params = "";
		var p = appletbox.getElementsByTagName("PARAM");
		for(var i=0; i < p.length; i++) {
			params += p[i].outerHTML;
		}
		appletTag = appletTag.replace("</APPLET>", params+"</APPLET>");
	}

	var isRequiredVersion = deployJava.versionCheck(requiredVersion);
	var text = ""
	var callback = ""

	if (isRequiredVersion) {
		text = "Click to play"
		callback = "showApplet()"
	} else {
		text = "You don't have java plugin enabled, click to install"
		callback = "installJava(\'" + requiredVersion + "\')"
	}

	// adds the screenshot inside the applet div
	var screenshotDivHtml = "<div id=\"screenshot\" class=\"play\" onclick=\""+callback+"\" style=\"width:"+width+"px; height:"+height+"px;\">";
	screenshotDivHtml += "<span>"+text+"</span>";
	screenshotDivHtml += "<img id=\"screenshotImage\" src=\""+screenshotUrl+"\" alt=\""+text+"\" width=\""+width+"px\" height=\""+height+"px\">"+"</img>";
	screenshotDivHtml += "</div>";

	appletbox.innerHTML=screenshotDivHtml;
}

function showApplet(){
	var appletbox=document.getElementById('applet');
	appletbox.innerHTML = appletTag;
}

function installJava(version) { 
	deployJava.installJRE(version);
}

You can see a working example here.

Thats all.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Games as Applets

Thursday, December 30th, 2010

As you may know, we are publishing our games in two formats, Applets and Webstart. Applets works in a similar fashion as a Unity or Flash applications does, you open the web page and the game loads inside it. Webstart applications starts as a desktop application, outside the browser.

In this post we will explain how we deal with Java Applets. One thing we didn't like about applets is that they starts as soon as you visit the page, sometimes you want to visit a game page only to see some information or read comments, etc.

We created a workaround for that, it consists in showing a game's screenshot with a text "click to play" and whenever a player clicks on it, the game is started.

Implementation

Our solution consist in a css with the styles to show the screenshot with the text and a javascript with the logic to change the screenshot with the Java Applet.

First we have styles to show the text over the screenshot and highlight it whenever the user moves the mouse over it.

Style:

  
.play {
	display:block;
	position:relative;
	-moz-opacity:0.80;
	opacity:0.80;
}

.play span {
	-moz-opacity:0.60;
	opacity:0.60;
	display:block;
	position:absolute;
	top:225px;
	z-index:100;
	width:100%;
	color: white;
	font-size: 80px;
	text-align: center;
}

.play:hover span {
	-moz-opacity:1;
	opacity:1;
	display:block;
	position:absolute;
	top:225px;
	z-index:100;
	width:100%;
	color: white;
	text-align: center;
}

Then, we have some javascript to create the screenshot div dynamically, and to replace it with the applet tag when the user clicks on it, or send the user to install the needed version of Java if he hasn't installed yet.

Javascript:

  
	var requiredVersion = '1.6.0_10+'
	var width = "640"
	var height = "480"
	var screenshotUrl = "floatingislands03.jpg"

	var url = "launch-applet.jnlp";
	var attributes = { code:'org.newdawn.slick.AppletGameContainer',  width:width, height:height} ; 
	var parameters = {jnlp_href: url}; 

	var isRequiredVersion = deployJava.versionCheck(requiredVersion);
	var text = ""
	var callback = ""

	if (isRequiredVersion) {
		text = "Click to play"
		callback = "startGame()"
	} else {
		text = "Click to install Java"
		callback = "installJava()"
	}

	var screenshotDivHtml = "
"; screenshotDivHtml += ""+text+""; screenshotDivHtml += "\""+text+"\""+""; screenshotDivHtml += "
"; var appletElement = document.getElementById('applet'); appletElement.innerHTML += screenshotDivHtml; function startGame() { var screenshotElement = document.getElementById('screenshot'); var appletElement = document.getElementById('applet'); appletElement.removeChild(screenshotElement); var oldwrite = document.write; var newHtml = ''; document.write = function (str) { newHtml += str; } deployJava.writeAppletTag(attributes, parameters); document.write = oldwrite; var realAppletElement = document.getElementById('realApplet') realAppletElement.innerHTML = newHtml } function installJava() { deployJava.installJRE(requiredVersion); }

Also, we will need to add two divs to the html to make the javascript to work.

Html:

  

That's all, if you want to take a look at a working example, click here.

VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)

Android development

Wednesday, September 29th, 2010

We have been wanting to try the Android platform for some time and just recently bought an HTC Desire phone (It rocks, not so much the multitouch implementation).

Right now we are:

  • Investigating the platform, going through the API and Best Practices, to see what kind of games we can do, and how easy it is.
  • Decoupling our engine from some libraries like Slick2d and Groovy in order to test if we can reuse it for Android development.

One huge issue with Android right now is that the market has support for selling apps from a little list of countries. Of course Uruguay which is where we are from is not one of those. So we have to see if we can make things that can be supported with ads, donations, other markets (not the main android market), or some other solution.

We will be making some update when we have more knlowledge about this interesting platform.

VN:F [1.9.22_1171]
Rating: 4.0/5 (1 vote cast)

New way to show our games

Friday, August 20th, 2010

As the title says, we have changed the way we were showing the games.

Now, we have a page for each game showing a screenshot, the game's description and links to play it as an applet or via webstart. This is the page where we would add any content about the game like videos, faq, reviews, comments, etc.

One objective of this change was to make applets more friendly letting you see information about the game before interrupting you with the applet loading and also a friendlier message when you don't have the correct version of the java plugin for your browser.

If you click on the play as applet link, a new page is displayed showing an image of the game and the game's instructions, you can load the applet by clicking on the image.

Hope you like the change.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)