Thursday, April 14, 2011

Python and Pygame For Android!

   I love Pygame. Python was the first real programming language I was able to grok and Pygame and its sprite system were a big motivator to finally figure out object-orientation. I made a bunch of different small games using Pygame before I decided to try and learn Actionscript 3, and I'll always have a use for Pygame in quick prototyping. So when I found the Pygame Subset for Android, I thought it was pretty darn spiffy.

   I knew Symbian and Maemo/Meego had some sort of Pygame port, but Android lacked one, until recently it seems. I don't think running Pygame on a smartphone is a great idea for projects that require a ton of fast drawing, but this is just too cool for a Python fan to avoid.

   I'm supposed to be writing a physics-based game in AS3 right now, but I'm having trouble coming up with game ideas beyond the prototype I've got running, so I think I'll take a break and port one of my old Pygame projects to my Inspire 4G. It'll be good to refresh my Python since it's been a while since I've done any new Python projects. I've been wanting to write something for my phone in Python anyway but the Scripting Layer for Android seems intended for shell-script type tasks, not making GUI apps and games.

   Having access to Pygame on my phone though is just brilliant, especially since it's possible to edit the code for a project on the device itself and just run it again, without needing to go back to a computer to compile or package anything. I ran the example Pygame code on my phone and used the text editor that came with the ES File Explorer app to change the colors to red and white instead of red and green, a simple example but it means I can actually code while on a bus or while waiting in line somewhere! I just think that's so awesome, it's certainly something I couldn't do on my Blackberry. It also makes the cheap mini Bluetooth keyboard I bought that much more useful, though I still wish I had a built-in keyboard on the phone itself.

   The Pygame Subset for Android doesn't support every feature of desktop Pygame but being able to write in Python and get a simple game running on Android seems like a great way for someone learning Python to also play with mobile development. The idea that I can code for my phone in Python and make games with Pygame is just so awesome, I'm still having trouble wrapping my brain around it.

2 comments:

  1. Hey cool. I played with SL4A a short while ago but it seemed limited to me with regard to interacting and manipulating images. I had not really thought about pygame, but now I'm going to give it a shot. Btw, have you ever dealt with compiling C extensions for Arm?

    ReplyDelete
  2. Nope, the only C stuff I've messed with has been limited to msp430 microcontrollers.

    ReplyDelete