Flappy (the name stands for FLash-like APi for PYthon) is a cross platform multimedia library with the API very similar to the ActionScript 3 Flash API. Flappy is built on top of the SDL2 library and a slightly modified subset of c/c++ code from the OpenFL-Lime project.
- Runs on Windows, Linux, Mac OS X
- GPU accelerated
- Drawing images, text, shapes, gradients
- Tile sheet batch rendering
- Flash-like display list, display objects, containers
- User input events and other events handling and propagation
- 3D graphics support
- Alpha version
- No Python 3.x support
- No sound playing
Install binary package
In Mac or Linux, try:
For windows, download the installer (one of Flappy-xxx.win32.exe files) here
Build from source
To build Flappy, Cython 0.19.1 or above is required.
Also the following libraries needed:
- freetype 2
- libpng 1.6
- libjpeg 6b
You can either install development versions of these libraries to your system (or already have them installed), and build and install Flappy like this:
python setup.py install
Or you can clone this repository to the same directory as Flappy's source directory and build and install with this command:
python setup.py build_extensions_with_waf --use-prebuilt-libs install
This code draws a black-outlined orange circle inside a window sized 400x400 pixels. Each time you click on that circle you'll see the string "YAY!" in console output:
import flappy from flappy.display import Sprite from flappy.events import MouseEvent class Example(Sprite): def __init__(self): super(Example, self).__init__() circle = Sprite() circle.graphics.lineStyle(4) circle.graphics.beginFill(0xff8000) circle.graphics.drawCircle(200, 200, 100) circle.graphics.endFill() self.addChild(circle) circle.addEventListener(MouseEvent.CLICK, self.on_circle_click) def on_circle_click(self, event): print 'YAY!' if __name__ == '__main__': flappy.start(Example, width=400, height=400, title='Example')
For the comparison, here is the code in ActionScript 3 which does the same.
For now, documentation is a stub. But you can take a look at ActionScript3 API reference for Flash. Classes and method in packages flappy.display, flappy.events, flappy.geom, flappy.text are very similar to the classes and methods in Flash's corresponding packages.
Also, see samples: