My little brother and I are doing some sibling bonding by working on an Android game together called Fighters of Agenthon (we are still in the early planning phase). We have decided to use libgdx, a cross-platform Java game framework based on OpenGL.
I have a fair amount of contempt for Android's love affair with the Eclipse IDE. I do my Android development with a text editor and the command-line, but, libgdx is also tightly coupled to Eclipse. So, my first matter of business was to make sure we could setup a reasonable CLI build environment.
We started by following the libgdx wiki article
Using Ant to build your libgdx project. Basically, our source tree is broken
up into 3 directories just like any other libgdx project. The main folder is
the cross-platform code and the bulk of the game logic. The android and the
desktop directories contain code specific to the Android platform and a desktop
platform respectively.
android/
assets/ <-- assets for ALL platforms
libs/ <-- libs for Android only
res/
src/ <-- source code for Android only
build.xml <-- build script for android APK
desktop/
libs/ <-- libs for Desktop only
src/ <-- source code for Desktop only
build.xml <-- build script for desktop only
main/
libs/ <-- shared libraries for all platforms
src/ <-- source code for all platforms (bulk of game code)
Each platform specific directory has it's own Ant build.xml which pulls in code
and libraries from the main directory to build the project.
The Android project uses a modified version of the default Android build script.
It is modified to include jars from main/libs/ and source code from main/src/.
The desktop project uses a custom Ant build script which, like the android
script, includes jars from main/libs/ and source code from main/src/. But, it
also pulls in the assets directory from android/assets since android is pretty
picky about the location of that directory.
The workflow looks something like this...
To compile and test the game on the desktop:
cd desktop
ant run
To build and test the game on an Android device or emulator:
cd android
ant debug
adb install -r build/agenthon-debug.apk
adb shell am start -n com.quixotix.agenthon/.MainActivity
These build scripts are still a work in progress, but, it's working out nicely so far. You can always peruse our Github repo to see how they evolve over the next few weeks.
