Where do I start to learn Pyxel?
It is recommended to try Pyxel's example code in the following order.
- 01_hello_pyxel — Pyxel basics
- 05_color_palette — Color palette
- 03_draw_api — Drawing API
- 04_sound_api — Sound API
- 02_jump_game — Game implementation
You can copy the examples with pyxel copy_examples, or run them in your browser on Pyxel Showcase.
Are there any books on Pyxel?
The official book is available in Japanese only.
What is the difference between the update and draw functions?
The update function is called every frame, but the draw function may be skipped if the processing time exceeds the allowable limit. This design in Pyxel reduces the impact of rendering load and OS interruptions, enabling smooth animation.
How do I use Pyxel's MML?
MML (Music Macro Language) is a language for defining sounds by describing notes, tempo, and other parameters as a string.
Passing an MML string to the mml function of the Sound class causes that Sound to be played according to the MML content. Calling mml() with no arguments clears the MML setting.
pyxel.sounds[0].mml("CDEFGAB>C")You can also play an MML string directly by passing it to the play function instead of a sound number.
pyxel.play(0, "CDEFG")For available MML commands, see Pyxel MML Commands. For usage examples, see the demo and code of the 09_shooter.py example.
You can also create and share MML in your browser using Pyxel MML Studio.
File cannot be loaded. It may fail when the environment changes.
Make sure that the current directory is set as intended when loading files.
When Pyxel's init function is called, the current directory is changed to the same location as the script file. After that, files can be specified using relative paths. However, loading may fail if you try to open a file before calling init or if the current directory is changed after calling init.
How can I save application-specific data like high scores or game progress?
Pass the developer name (vendor_name) and application name (app_name) to the user_data_dir(vendor_name, app_name) function. It will return the path to a directory suitable for data storage on the current platform. Use this directory to save and load your application's files.
Can I try Pyxel without installing it?
With Pyxel Code Maker, you can create and run Pyxel apps in your browser. However, it does not support multi-file projects, so a local environment is recommended for full-scale development.
Pyxel Showcase lets you browse and run sample code and apps in your browser.
How do I publish my Pyxel app on the web?
There are three methods: Web Launcher, app2html, and Custom Tags. For details, see How to Use Pyxel for Web.
Can I change the palette colors in Pyxel Editor?
By placing a file with the same name but with the .pyxpal extension in the same directory as the Pyxel resource file (.pyxres), the palette display colors in Pyxel Editor will be updated. Palette files can be created with the save_pal function, or manually as a text file with one hex color code per line.
How to migrate code to version 2.4
In Pyxel 2.4, the sound engine and MML syntax have been revamped.
To make your code compatible with version 2.4, please make the following changes:
- Rename the
waveformfield of the Tone class towavetable - Change the
tickargument of theplayandplaymfunctions tosec(a float value in seconds) - Update code to handle the return value of the
play_posfunction, which is now(sound_no, sec) - Change the
countargument of thesavefunction in the Sound and Music classes tosec - If you need the playback duration of a sound, use the
total_secfunction of the Sound class - For the Sound class's
mmlfunction, use code that follows the new MML syntax - To use the old MML syntax, use the Sound class's
old_mmlfunction - Change the
excl_*option in thesaveandloadfunctions toexclude_* - Remove the
incl_*option from thesaveandloadfunctions
For details on the new MML syntax, see "How do I use Pyxel's MML?" above.
Can I use Pyxel for commercial purposes without the author's permission?
As long as you comply with the MIT License and clearly display the full text of the copyright and license in the source code or license file, you are free to sell or distribute it without the author's permission. However, since Pyxel is developed by a single individual, it would be appreciated if you could contact the author or consider sponsoring their work if possible.