BennuGD for Android preview release!

Good news, everyone!
Today I'm releasing a very alpha, preview release of BennuGD for Android. It corresponds to revision 418 in the bennugd-monolithic source code tree and you can see a small video of a demo video (recorded with my iPad 2!) of Puzsion running in my Android phone below:
The video is from a couple of days ago; that's why I don't show game interaction as a couple of days ago multitouch events weren't being emulated as mouse events.
So, a couple of warnings:

  • This is alpha quality code and you're supposed to know what you're doing if you want to use it. If you break it, then I'm sorry.
  • Sound doesn't work. You can load mod_sound but if you try to play a couple of sounds at a time, your app will break. This appears to be a SDL2 bug that needs to be fixed.
    For now I'm using the following code to suppress audio in testing games:
    #ifdef FAKE_SOUND
    #define stop_wav(a);
    #define stop_song(a);
    #define set_channel_volume(a,b);
    #define set_song_volume(a);
    #define unload_wav(a);
    #define unload_song(a);
    #define load_wav(a) 0
    #define load_song(a) 0
    #define play_wav(a, b);
    #define play_song(a, b);
    #define fade_music_off(a);
    #define pause_song(a)
    #define resume_song(a)
    #define ALL_SOUND 0
    #endif
  • Anything related to set_mode() beyond setting a video mode is either not working or untested. This includes scaling and rotation. Also, when setting the video mode be sure to set it to your device's display depth (usually 32bpp). Setting the video mode to a size different to your device's native seams to work fine, though.
    You can, however, set rotation by modifying AndroidManifest.xml's android:screenOrientation value to any value described here. This is faster than BennuGD's implementation and works just fine.
  • Touch events will ONLY be emulated as mouse events if you import BOTH mod_mouse and mod_multi.
  • This code should include all the official modules (minus mod_debug) plus mod_multi and mod_curl for handling multitouch input and server-client communications.
  • Anything activity-based in totally untested: you're responsible for what your app does when in the background. Also, coming back from the background won't probably work, so be sure to make your app die when sent to the background, but I don't know if that's working (refer to the first point if you need clarifications).
  • I don't yet know where to store your game's data (savegames, highscores...) in your phone, sorry. See first point in this list for more info :)
  • You can use say() for printing debugging info. It'll appear with a "W/SDL/APP" prefix in the adb logcat and I like to filter the ouput of the logcat like this:
    adb logcat SDL/APP:* SDL:* *:S
  • You can only set_mode once, and you must do it yourself. This version of BennuGD won't do it for you even if official BennuGD does.
  • Please, report any bugs here. Reporting bugs elsewhere will probably result in me forgetting about it and. So please, ONLY report bugs there.
Now, for your question: "How do I get an APK from your package", here's a step-by-step tutorial:
  • Get the Android SDK from here and set it up for your system. I don't use Eclipse and don't know how to compile the code with it, sorry.
    Also, be sure to install API 10 -Android 2.3.3- from the Android SDK manager. BennuGD might work in Android 2.2, but I use API 10.
  • Install ant.
  • Plug in your device or start the Android emulator. Be sure to enable debugging in the device.
  • Open your console and browse to the path where you uncompressed the BennuGD for Android template.
  • Modify local.properties to point to where you've installed the Android SDK.
  • Type "ant debug install". This should install a debugging version of the sample program in your device and you'll be able to test whether everything is working properly.
    If it's working fine, you can now try to get your game to work.
  • To do so, store your game's content in the "res" directory and be sure to rename your game's main DCB as "main.dcb".
    Then remove the "bin" directory and re-execute "ant debug install". If everything went fine, your game should now be installed in your phone! Congrats :)
<<Get the code from here>>

Android port progress, multitouch module

Yesterday I finally got a couple of important things working regarding BennuGD on Android:
First of all, the guys working on SDL workarounded what appears to be a bug in Android that caused APK resource loading to fail, so now you can just package your game's resources into the APK and directly load them from there. There's nothing special you have to do from your BennuGD code. Up until now you'd had to use resources found in the user's SD card, which isn't particularly useful...

Another important thing is multitouch support: Yesterday I created a module to support multitouch. It's based in SDL 1.3 so it should work in both iOS & Android (and on desktops too, if you're still using that sort of devices :P), although I have just tested it in Android. It's still quite buggy but it's working. You can see a very simple preview of how it's working (the sample has some background music although I'm not sure it can be heard in the video) below:

The video is pretty crappy, but you get the idea.
Also, touch sensitivity is better than it looks like in the video.

Those are two very important things to have working for a game engine running on Android so I'm quite happy to see them working.

As per the work left regarding the Android port of BennuGD before we can call it a release, the list of things to do goes as follows:
  • Fix image loading: The colormode for PNG loaded images is not working as expected (yet). Not sure about other formats.
  • Handle rotation: The programmer should have a way to control how they want the phone to respond to rotations when their game is working.
  • I believe that right now we don't have a way to know when the app is in second plane->let the programmer know it through mod_wm.
  • Fix set_mode. Right now the video mode is set for you to your device's default resolution and, if you call set_mode again, Bennu crashes.
  • learn where the programmer must keep their persistent data.
  • [Update mod_chipmunk+compile mod_sqlite3 in].
  • Test it!
Get your little green devices ready because BennuGD is coming!

Blog Archive