-
Python & Android: Getting Started
Welcome, citizens of Checkiopolis
The purpose of this article is not just to show that it's possible to write applications for android, but to show that there's already stable and popular tools to write Android games and applications using your favorite language — Python.
Android is currently one if not the most popular mobile operating systems. It powers hundreds of millions of mobile devices in more than 190 countries from all around the world. It has the largest install base of any mobile platform and is growing fast. Every day another million users power up their new Android devices for the first time and start looking for apps, games, and other digital content. Android gives you a globalized platform for publishing apps and games for users everywhere, with a widely used open marketplace for instantaneous distribution.
Because you happened to find yourself reading this article, I assume that you're interested in Python and you already know why it is awesome, so I won't waste your time convincing you to try it, so let's just jump straight into our first and one of the most popular frameworks to work with Android — PGS4A.
Pygame Subset for Android
Pygame applications can run on Android phones and tablets with the use of the Pygame Subset for Android. Sound, vibration, keyboard, accelerometer are supported on Android. There is currently no way to run Pygame applications on iOS. Another major limitation of PGS4A is the lack of multi-touch support, which prevents the use of things like pinch to zoom and two-finger rotation. An alternative to running Pygame Subset for Android is to use Kivy, which includes multi-touch and iOS support.
And now the star of our tools roundup - Kivy!
Kivy
Kivy is an Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. Kivy runs on Linux, Windows, OS X, Android and iOS. You can run the same code on all supported platforms. It can use natively most inputs, protocols and devices including WM_Touch, WM_Pen, Mac OS X Trackpad and Magic Mouse, Mtdev, Linux Kernel HID, TUIO. A multi-touch mouse simulator is included. Kivy is 100% free to use under an MIT license (starting from 1.7.2) and LGPL 3 for the previous versions. The toolkit is professionally developed, backed and used. You can even use it in a commercial product.
The framework is stable and has a well documented API, plus a programming guide to help you get started. GPU Accelerated The graphics engine is built over OpenGL ES 2, using a modern and fast graphics pipeline.
The toolkit also comes with more than 20 widgets, all highly extensible.
Kivy is an example of a well written and well documented piece of software which can be extremely helpful for novice programmers, so it's very easy to begin writing feature complete apps.
Here's some examples of games and applications built using Kivy:
•There's an official tutorial on how to build simple Pong game with Kivy
•Deflectouch is a multitouch game for, with and because of Kivy. This game won Kivy's First Programming Contest and taken the 1st place (video)
•Python+Kivy is based version of world's famous 2048 game
You can find Kivy and lots of other examples by googling or you can check out official list of Kivy written apps and games
IGNIFUGA
Ignifuga is a multi platform (Windows/Linux/OS X/iOS/Android) 2D hardware accelerated engine based on Python and Cython, inspired by similar offerings like Cocos2D, Cocos2D for iPhone, and AndEngine. All your game logic code, the engine and supporting tools are converted to C during the build process, then compiled into one big standalone binary for each of the supported platforms (you can refer to the FAQ for more information)
QPython
QPython - with Python on Android in most cases, scripts can get the job done as well as a native application. Now you can make it even easier with QPython's help. QPython is a script engine which runs Python programs on android devices. It also can help developers develop android applications. QPython includes a complete development kit which helps you to develop programs for mobile. QPython is powerful, and you can extend it as you see fit. The getting started and programming guide will help you to easily get to developing your apps and scripts
Pyglet
Pyglet is a library for Python which provides an object-oriented application programming interface. This provides the right tools to make the creation of games and other multimedia applications even easier. Pyglet runs on Microsoft Windows, Mac OS X, and Linux. It was released under a BSD Licence. It supports windowed and full-screen operation, and multiple monitors. Images, video, and sound files in a range of formats can be done natively, with more additional capabilities supplied by the optional AVbin plugin, which uses theLibav package to provide support for audio formats including MP3, Ogg/Vorbis, and Windows Media Audio, and video formats such as DivX, MPEG-2, H.264, WMV, and XviD.
This is just the quick glance on the first part of the a multi-part Android+Python development series. There's still lot's of cool and useful stuff to cover and discuss. Where it goes from here will depend on your feedback and interests. Heck, if people would like, we could write up a set of Kivy programming tutorials for complete beginners.
See you guys next Wednesday, happy coding and good luck!
Welcome to CheckiO - games for coders where you can improve your codings skills.
The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.
Join the Game