Sunday, March 31, 2013

Lesson 5 - Going Mobile - Python on Android

Part one covers Python code modification.  Part two covers Android phone settings and configuration of Pygame Subset for Android.

Part 1

Technical points of part 1:
  • import android library and handle exceptions
  • map keyboard ESC key to Android back key (hard button) on phone
  • quit game if phone back key is pressed

Part 2

Technical points of part 2:
  • Set Android phone to debug mode
  • Configure game build with pgs4a
  • Build, package, install
  • Test game


  1. When I try import android and android.init(). I got errors so I try to use my pygame test without importing android module and working fine on my tablet (android os 4.0.2) . See my tutorial about this :

    1. Catalin, thanks for sharing this. I read through your tutorial and it looks like you're off and running. This is great. Hopefully, other people will benefit from your information.

      It seems like there are many quirks with using pgs4a. For teaching purposes, it might be good to have a standard environment like a VM with standard libraries and tools in it. It seems like most comments I receive deal with pgs4a configuration. Ideally, the kids should be able to focus on learning things like data structures instead of spending precious time on pgs4a configuration. The only reason I introduced pgs4a is that the attraction of running the application on a mobile phone was so great for teenagers. They like to show their friends mobile games, so I took that path.

      However, it seems too daunting to show pgs4a configuration on web site.

      thanks again for sharing your tutorial with other people.

    2. Also, how do you quit the game on the phone if you don't remap the Android backspace key to something like ESC? Do you have a button you made on the screen to quit the game that is always on the screen?