- Create some Python code
- Create a file like
- Add the import
from dragon.transpiler.python_to_haxe_transpiler import PythonToHaxeTranspiler
PythonToHaxeTranspiler(source_path, files).transpile()passing in the directory root of the source files (important for package names!) and a list of files to transpile (eg.
- Check the outputted Haxe code. Invoke the Haxe compiler as usual.
For constructs that don't exist in Python (eg.
@:...), add them to your Python code and prefix them with
- When importing Haxe code, use the Haxe-style
from package.subpackage import ClassName
- Make sure all Python files have a final empty line
Dragon was created in order to be able to write HaxeFlixel games in Python. Python supports complex features (eg. generator functions, decorators) and ships with a vast collection of functionality (eg.
decimal, etc.); it would be impossible to keep Dragon up to date.
Instead, Dragon supports just enough functionality to build games. If you find your favourite feature or module missing, feel free to open an issue or send us a PR.
Currently, Dragon is in a very early stage of development. We're using Lark to generate the parse tree, and then generate the resulting Haxe code.
- Transpile the default HaxeFlixel "hello world" template (v0.1)
- Transpile a more complicated HaxeFlixel template
- Transpile an actual HaxeFlixel game
Once we achieve these goals, we plan to release the
v1.0.0 version of Dragon.
You may also be interested in Mars, our companion project which handles generating, compiling, and running Python-based HaxeFlixel projects (via Dragon).