"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Wednesday, 4 December 2013

Fun programming: Andengine

Here I am back on the “Fun programming” theme: finding ways to have some fun while programming. A way I use to detach myself from daily routine while seeking for new techniques or languages to learn. While visiting back this blog I noticed many articles about Andengine: a promising 2D games engine for Android developed by Nicolas Gramich.

Setting-Up Andengine

The starting point so set-up a working Andengine environment is to have a working Android development set-up based on Eclipse and Android SDK. I had prepared it before during my previous Android experiments. Also is needed a Git plug-in for Eclipse, like EGit.

Andengine is available as a Android library project it can be easily downloaded from its GitHub page by selecting Eclipse import wizard (Choosing the “File → Import …” menu first then the “Git → Projects from Git” option).
After copying the project URI in the wizard request …
The project branch must be selected, I did choose the GLES2 branch the latest and the one currently under develop.
at last the selection of a proper project path …
the project download eventually started and in a couple of “Next” button clicks I had my copy of the Andengine project.
At first the Andengine didn't compile because of a invalid target error. This could be because I didn't download all available targets while installing ADK tool. After selecting an available target from project properties it compiled without other problems.

First project … almost hello-world

To set-up my first Andengine project I started by creating the most basic Android application using the “Android Application Project” wizard
then selecting, among other options, to create only a “Blank Activity”.
I then transformed the activity code into the test project suggested by many tutorial in the 'net.

The code does nothing more than displaying a solid-colored background. Not even a hello-world but is enough to check if the engine has been correctly set-up.

Andengine Examples

The downside of Andengine is the lack of documentation. There are, of course, plenty of resources, tutorials and a good community on the Internet but a real documentation is missing. The best documentation available is a sort of documentation-by-example:AndengineExamples” is a project, developed from the same author, a sort of Andengine capabilities showcase. AndengineExamples cam be downloaded from GitHub like Andengine itself.
AndengineExamples relies on many “Extensions”, android libraries developed by Nicolas Gramich that take care of particular game aspects. Since the 'Examples is a showcase project it links almost all available extensions. I had to download from GitHub all the needed extensions to eventually compile the 'Examples project. Unfortunately my LG L3 phone doesn't have enough free memory tu run the Examples project but at least I have my documentation-by-example available in Eclipse aside to my projects.