Metadata-Version: 2.4
Name: pyxel-reload
Version: 0.2.2
Summary: Run your pyxel applications, reloading when code / assets change
Author: Reiner Gerecke
License: MIT License
        
        Copyright (c) 2024 Reiner Gerecke
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: pyxel>=2.2
Requires-Dist: watchfiles>=1.0.3
Description-Content-Type: text/markdown

# 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

![](error-overlay.png)

## 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()
```
