# pyxel
**Repository Path**: spyhooky/pyxel
## Basic Information
- **Project Name**: pyxel
- **Description**: Python做的游戏
- **Primary Language**: Python
- **License**: MIT
- **Default Branch**: develop
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2024-12-03
- **Last Updated**: 2024-12-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
#
[](https://pypi.org/project/pyxel/)
[](https://github.com/kitao/pyxel)
[](https://github.com/kitao/pyxel)
[](https://github.com/sponsors/kitao)
[](https://ko-fi.com/H2H27VDKD)
[ [English](README.md) | [中文](docs/README.cn.md) | [Deutsch](docs/README.de.md) | [Español](docs/README.es.md) | [Français](docs/README.fr.md) | [Italiano](docs/README.it.md) | [日本語](docs/README.ja.md) | [한국어](docs/README.ko.md) | [Português](docs/README.pt.md) | [Русский](docs/README.ru.md) | [Türkçe](docs/README.tr.md) | [Українська](docs/README.uk.md) ]
**Pyxel** is a retro game engine for Python.
With simple specifications inspired by retro gaming consoles, such as displaying only 16 colors and supporting 4 sound channels, you can easily enjoy making pixel-art-style games.
The development of Pyxel is driven by user feedback. Please give Pyxel a star on GitHub!
## How to Install
### Windows
After installing [Python3](https://www.python.org/) (version 3.8 or higher), run the following command:
```sh
pip install -U pyxel
```
When installing Python using the official installer, make sure to check the `Add Python 3.x to PATH` option to enable the `pyxel` command.
### Mac
After installing [Homebrew](https://brew.sh/), run the following commands:
```sh
brew install pipx
pipx ensurepath
pipx install pyxel
```
To upgrade Pyxel after installation, run `pipx upgrade pyxel`.
### Linux
After installing the SDL2 package (`libsdl2-dev` for Ubuntu), [Python3](https://www.python.org/) (version 3.8 or higher), and `python3-pip`, run the following command:
```sh
sudo pip3 install -U pyxel
```
If the previous command fails, consider building Pyxel from source by following the instructions in the [Makefile](Makefile).
### Web
The web version of Pyxel does not require Python or Pyxel installation and runs on PCs, smartphones, and tablets with supported web browsers.
For detailed instructions, please refer to [this page](docs/pyxel-web-en.md).
### Try Examples
After installing Pyxel, you can copy the examples to the current directory with the following command:
```sh
pyxel copy_examples
```
The following examples will be copied to your current directory:
| 01_hello_pyxel.py | Simplest application | Demo | Code |
| 02_jump_game.py | Jump game with Pyxel resource file | Demo | Code |
| 03_draw_api.py | Demonstration of drawing APIs | Demo | Code |
| 04_sound_api.py | Demonstration of sound APIs | Demo | Code |
| 05_color_palette.py | Color palette list | Demo | Code |
| 06_click_game.py | Mouse click game | Demo | Code |
| 07_snake.py | Snake game with BGM | Demo | Code |
| 08_triangle_api.py | Demonstration of triangle drawing APIs | Demo | Code |
| 09_shooter.py | Shoot'em up game with screen transitions | Demo | Code |
| 10_platformer.py | Side-scrolling platform game with map | Demo | Code |
| 11_offscreen.py | Offscreen rendering with Image class | Demo | Code |
| 12_perlin_noise.py | Perlin noise animation | Demo | Code |
| 13_bitmap_font.py | Drawing a bitmap font | Demo | Code |
| 14_synthesizer.py | Synthesizer using audio expansion features | Demo | Code |
| 15_tiled_map_file.py | Loading and drawing a Tile Map File (.tmx) | Demo | Code |
| 16_transform.py | Image rotation and scaling | Demo | Code |
| 99_flip_animation.py | Animation with flip function (non-web platforms only) | Demo | Code |
| 30sec_of_daylight.pyxapp | 1st Pyxel Jam winning game by Adam | Demo | Code |
| megaball.pyxapp | Arcade ball physics game by Adam | Demo | Code |
| 8bit-bgm-gen.pyxapp | Background music generator by frenchbread | Demo | Code |
You can drag and drop an image file (PNG/GIF/JPEG) into the image editor to load the image into the currently selected image bank.
**Tilemap Editor**
The mode for editing **tilemaps** that arrange images from the image banks in a tile pattern.
Drag and drop a TMX file (Tiled Map File) onto the tilemap editor to load its layer in the drawing order that corresponds to the currently selected tilemap number.
**Sound Editor**
The mode for editing **sounds** used for melodies and sound effects.
**Music Editor**
The mode for editing **musics** in which the sounds are arranged in order of playback.
### Other Resource Creation Methods
Pyxel images and tilemaps can also be created using the following methods:
- Create an image from a list of strings using the `Image.set` function or the `Tilemap.set` function
- Load an image file (PNG/GIF/JPEG) in Pyxel palette with `Image.load` function
Pyxel sounds can also be created using the following method:
- Create a sound from strings with `Sound.set` function or `Music.set` function
Refer to the API reference for the usage of these functions.
### How to Distribute Applications
Pyxel supports a dedicated application distribution file format (Pyxel application file) that is cross-platform.
A Pyxel application file (.pyxapp) is created using the `pyxel package` command:
```sh
pyxel package APP_DIR STARTUP_SCRIPT_FILE
```
If you need to include resources or additional modules, place them in the application directory.
Metadata can be displayed at runtime by specifying it in the following format within the startup script. Fields other than `title` and `author` are optional.
```python
# title: Pyxel Platformer
# author: Takashi Kitao
# desc: A Pyxel platformer example
# site: https://github.com/kitao/pyxel
# license: MIT
# version: 1.0
```
The created application file can be run using the `pyxel play` command:
```sh
pyxel play PYXEL_APP_FILE
```
A Pyxel application file can also be converted to an executable or an HTML file using the `pyxel app2exe` or `pyxel app2html` commands.
## API Reference
### System
- `width`, `height`
- `bltm(x, y, tm, u, v, w, h, [colkey], [rotate], [scale])`
- `text(x, y, s, col)`