https://github.com/squiddy/pyxel-reload
A hot-reloading development tool for Pyxel games that automatically refreshes your game when code or asset files change.
https://github.com/squiddy/pyxel-reload
game-development pyxel
Last synced: 11 months ago
JSON representation
A hot-reloading development tool for Pyxel games that automatically refreshes your game when code or asset files change.
- Host: GitHub
- URL: https://github.com/squiddy/pyxel-reload
- Owner: squiddy
- License: mit
- Created: 2024-12-12T20:28:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-11T10:31:23.000Z (over 1 year ago)
- Last Synced: 2025-07-02T13:50:44.110Z (12 months ago)
- Topics: game-development, pyxel
- Language: Python
- Homepage:
- Size: 282 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyxel-reload
A hot-reloading development tool for [Pyxel](https://github.com/kitao/pyxel) games that automatically refreshes your game when code or asset files change.
## Features
- Hot reloading of Python code changes
- Automatic reloading when .pyxres asset files change
- Error display in both console and game window
- Simple integration with existing Pyxel games
## Installation
Install via pip:
```bash
pip install pyxel-reload
```
## Usage
1. Ensure your game file has an `update` and `draw` function
```python
import pyxel
pyxel.init(160, 120)
def update():
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw():
pyxel.cls(0)
pyxel.text(10, 10, "Hello, Pyxel!", pyxel.frame_count % 16)
pyxel.run(update, draw)
```
2. Run your game with pyxel-reload:
```bash
pyxel-reload game
```
Where `game` is the name of your Python module (without the .py extension).
3. Make changes to your code or .pyxres files and see them reload automatically!
## Error Handling
When errors occur during reload:
- Error details are displayed in the console
- A basic error message appears in the game window
- The game continues running and will reload once errors are fixed

## Run code before reload
If you need to run some code before the game is reloaded, you can define a
`on_unload` function in your game module:
```python
def on_unload():
stop_music()
```