... well...
At least some of the code seems to me helpful in trying to understand this type of games. I still haven't found what am looking for in a tutorial about puzzle games... there aren't many around.
... What are the *.tex files for? Are them of any use?
Also... there is some "bg.png" missing... I just renamed a copy of "balls-3x3.png" as a dirty replacement for it to run. Fail to see where it is needed/referred to yet...
This could be made in to a nice tutorial! Mind commenting the code and expanding the game?