Monday, August 26, 2013

Tiled JSON Map Loader Example Code Available

Someone asked me for the source code for the JSON map loader example I created for a video tutorial on using Tiled to export 2d tile maps as JSON map files. Although .tmx is a more popular format, Pygame Subset for Android does not support the xml parser libraries.  Because of this, we can't use the TMX Loader library available on the Pygame site.  Pytmxloader also will not work.  This is unfortunate since the pytmxloader is especially nice.  Although these libraries will work on the desktop.  They will not work on the Android phone.  :-(

At some point, I was planning to write a library for JSON map file loading.  However, I never got around to it.  The code below will work on desktop and mobile phones.  It is for educational purposes only.



JSON Map Loader Lesson Code that works with Tiled maps.




Sunday, August 25, 2013

Installing Pygame Subset for Android


I noticed that a new version of pgs4a came out.  I upgraded from 0.9.4 to 0.9.6 this morning.  The process went smoothly on my Ubuntu 12.04 LTS system.  I was up and running in 10 minutes and my programs ran with no problems.

Since the installation on Linux normally goes fine, I suspect that many of the problems people have with pgs4a is not due to the installation, but due to usage.

Here are three common problems I've heard about:

1) You're not specifying the directory of your application.  Many people will configure and build the name of the python file.  This is wrong.  You need to specify the name of the directory.


The location specified after build is the name of the directory, not the file.

2) You didn't name your main python file main.py.   You may have called the file something like runner.py or angryfish.py.  This is wrong.  The file needs to be called main.py.

3) You didn't initialize the android library in  your python code.


Then, there are cases where everything should be working, but it's not. Assuming that you installed the android sdk with the command.

 then your adb tool will be in android-sdk/platform-tools.

The most useful command will be ./adb help followed by ./adb logcat.   With your phone connected to your computer with a USB cable, running ./adb logcat will give you the logs from your phone.  By reading through the logs, you should be able to get some clues as to why your program is failing.




Match Game Lesson, Lists and Dictionaries


New lesson on a match game with lists and dictionaries.

The code for this lesson is available on bit bucket here.