Sunday, November 11, 2012

Playing with PlayN: Kick-Ass Crossplatform Game Development

When looking at its main sites, its hard believe that its been more than one year since Google revealed PlayN, then known as ForPlay, to the general public. The amazing technology allows to develop a game in java and target almost any platform: HTML5, Android, ios, Flash, Java (and XNA someday?).

Disclamer: I'm not a Java developer. I knew nothing of Maven, Ant, GWT, war files, JAVA_HOME, JAVA_JRE, just yesterday. It took me many hours to make the sample projects work.

First I had to install the JRE and eclipse, by default it downloaded the 32 bits JRE which did not work with the 64 bit eclipse I had downloaded, I also installed Git and got the samples. I tried to follow the eclipse guide but I encountered many unexpected errors. Most of which I found solutions by googling. A link leading to a maven related .jar file was broken and I had to download it manually and put it in my .m2 folder in my MyDocuments folder. Don't ask me why it puts all the jar files there, I was surprised when I could not find them in my projects.

Starting the samples in eclipse did not work, I had to use the ant method, I found the location of the ant eclipse comes with, added it to my PATH and ran the ant commands in the guide. An other annoyance was that the java source paths in eclipse were not set correctly so I could not follow declarations in the source.

I also installed Tomcat and realized how easy it is to deploy the generated HTML5 version.

So the getting started doc and maven project might need some fixing. Then I realized that the version of playN in the sample is not the latest release, also, the latest version has many improvements listed in the release notes. I set myself to find out how to generate a PlayN 1.4 project.

I tried to generate the project with eclipse but it just does not work, there is a problem with Maven and many discussion threads on the web suggested generating the project with the stand alone version of maven (not the Eclipse plugin). So I install the JDK (needed for Maven). Installed Maven.

The command to generate the project was not too hard to guess:
mvn archetype:generate -DarchetypeGroupId=com.googlecode.playn -DarchetypeArtifactId=playn-archetype -DarchetypeVersion=1.4

Then I imported the project in eclipse. Unlike the sample projects, the dependencies between projects are not set correctly for the skeleton projects. RunAs->Maven Test did not work at first on any of the projects, I had to do RunAs->Maven Install on the core project, then RunAs->Maven Install on the HTML5 and Java projects (the versions I want to work with). After doing these RunAs->Maven Test did work on both the HTML5 and Java.

I'm still confused about the structure of the projects. There is a project for each platform and then there is an appname-core and appname project which both contains the same source files, but one of them is not considered as a Java project. I'm not sure how I'm is supposed to work, where to put the unit tests, what are all those Maven commands, ect.

So, to come back to the main subject, its hard to believe that the main site is in that state. With that amazing technology, show-cased by on of the most popular mobile games (Angry Birds), one would think that there would be a community out there and that the documentation would be abundant, and that it would be easy to get started. Also I could not find a link the google developers page. I had to seach for playN on the site, while way less interesting project are advertised in the game section. What I understand is that Maven thing is supposed to make things work automagically, but by not working it makes the whole process complicated. Probably, bearded seasoned Java/Maven/Eclipse/GWT developers out there have no problem setting their own project how they like and are too lazy to update the docs and sample projects. That's too bad, think of all the fun kids could have making their own games and deploying them on the web. If not for the problems related to the maven projects, PlayN would be a great introduction to programming and game making. The engine itself looks easy to program, and the Java and HTML5 are easy deploy.

Interesting links:









2 comments:

  1. I had a problem where I could build and run the html version of the game, but it would be the original empty skeleton, not containing my modification which would appear in the Java version.

    The problem was that the local maven repository would not be updated with the core of the game, so the html version would always compile with with what ever was there.

    The solution:
    in app/core run mvn clean install -U
    in app/ run mvn clean install -U
    in app/ run mvn Phtml clean integration-test

    ReplyDelete
  2. The most curious is that the flash target of the current version (1.6) doesn't work at all, even after resolving of the missing maven dependencies.

    ReplyDelete